Python 3.12.6 (tags/v3.12.6:a4a2d2b, Sep  6 2024, 20:11:23) [MSC v.1940 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
# Nombre del archivo : Seccion_endulzamiento.py
# Autor             : William Fernando Noriega Anaya
# Fecha             : 16/08/2023
# Descripción       : Script para el diseño y el cálculo de emisiones de 
#                     gases de efecto invernadero (CO2 y CH4)
#                     en plantas de endulzamiento de gas natural
#                     con dietanolamina (DEA).
# Versión           : 1.0
################################################
#==============INICIO MÓDULO ENDULZAMIENTO=====#
################################################

#VENTANA OPCIONES SELECCION (Diseño o Emisiones)
    
import tkinter as tk
from tkinter import *
from tkinter import ttk
from math import exp, log
from PIL import ImageTk, Image
import numpy as np
from scipy.optimize import fsolve
import math
from PIL import ImageTk, Image

def ventana_endulzamiento():
    # crea la seleccion principal
    seleccion = Toplevel()
    seleccion.title("Selección")
    seleccion.resizable(0, 0)
    seleccion.configure(bg="white")
    seleccion.geometry("600x380+430+110")


    #Líneas Verticales y Horizontales
    #linea Vertical Izquierda
    lvi=Label(seleccion, relief="groove")
    lvi.place(x=10, y=10, width=2, height=360)
    #linea Vertical Derecha
    lvd=Label(seleccion, relief="groove")
    lvd.place(x=590, y=10, width=2, height=360)
    #linea vertical medio
    lvm=Label(seleccion, relief="groove")
    lvm.place(x=300, y=20, width=2, height=340)
    #linea Horizontal Superior
    lhs=Label(seleccion, relief="groove")
    lhs.place(x=10, y=10, width=580, height=2)    
    #linea Horizontal Inferior
    lhi=Label(seleccion, relief="groove")
    lhi.place(x=10, y=370, width=580, height=2)

    # crea las imágenes
    imagen1 = Image.open("Hotpot.png")
    imagen1 = imagen1.resize((260, 200), Image.LANCZOS)
    imagen1_tk = ImageTk.PhotoImage(imagen1)
    imagen2 = Image.open("Hotpot.png")
    imagen2 = imagen2.resize((260, 200), Image.LANCZOS)
    imagen2_tk = ImageTk.PhotoImage(imagen2)


    #Funcion que llama la ventana diseño
    def ventana_diseño():
        #Configurar la ventana. Titulo, tamaño y color de fondo
        composicion=Toplevel()
        composicion.title("Datos de entrada para el diseño de la planta de endulzamiento con DEA")
        composicion.geometry("740x520+340+50")
        composicion.configure(bg='white')
        #Permite que el usuario no maximice la pagina
        composicion.resizable(0,0)


        #Líneas Verticales y Horizontales
        #linea Vertical Izquierda
        lvi=Label(composicion, relief="groove")
        lvi.place(x=10, y=10, width=2, height=500)
        #linea Vertical Derecha
        lvd=Label(composicion, relief="groove")
        lvd.place(x=730, y=10, width=2, height=500)
        #linea Vertical medio
        lvm=Label(composicion, relief="groove")
        lvm.place(x=315, y=20, width=2, height=480)
        #linea Horizontal Superior
        lhs=Label(composicion, relief="groove")
        lhs.place(x=10, y=10, width=720, height=2)    
        #linea Horizontal Inferior
        lhi=Label(composicion, relief="groove")
        lhi.place(x=10, y=510, width=720, height=2)
        #linea Horizontal media
        lhm=Label(composicion, relief="groove")
        lhm.place(x=325, y=275, width=395, height=2)

        #Etiquetas Título Composición
        etiquetatcomp = Label(composicion, bg="white", text="Composición del Gas", relief="flat")
        etiquetatcomp.place(x=40, y=30, width=120, height=30)

        #Etiquetas de los Título Componente y Fraccion molar
        etiquetacomponente = Label(composicion, text="Componente", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetacomponente.place(x=60,y=65, width=100, height=20)
        etiquetafmolar = Label(composicion, text="Fracción Molar", relief="flat", bg='white', fg="gray26")
        etiquetafmolar.place(x=170,y=65, width=100, height=20)

        #Crear las variables de control donde se almacenan los datos
        num1_var = tk.DoubleVar(value=0.8692)
        num2_var = tk.DoubleVar(value=0.0393)
        num3_var = tk.DoubleVar(value=0.0093)
        num4_var = tk.DoubleVar(value=0.0026)
        num5_var = tk.DoubleVar(value=0.0029)
        num6_var = tk.DoubleVar(value=0.0014)
        num7_var = tk.DoubleVar(value=0.0012)
        num8_var = tk.DoubleVar(value=0.0010)
        num9_var = tk.DoubleVar(value=0.0008)
        num10_var = tk.DoubleVar(value=0.0172)
        num11_var = tk.DoubleVar(value=0.0413)
        num12_var = tk.DoubleVar(value=0.0122)
        num13_var = tk.DoubleVar(value=0.0016)
        num14_var = tk.DoubleVar()
        num15_var = tk.DoubleVar(value=100.2)
        num16_var = tk.DoubleVar(value=0.79)
        num17_var = tk.DoubleVar(value=50)
        num18_var = tk.DoubleVar(value=1000)
        num19_var = tk.DoubleVar(value=80)
        num20_var = tk.DoubleVar(value=2)
        num21_var = tk.DoubleVar(value=4)
        num22_var = tk.DoubleVar(value=35)
        num23_var = tk.DoubleVar()
        num24_var = tk.DoubleVar()
        num25_var = tk.DoubleVar()
        num26_var = tk.DoubleVar()
        num27_var = tk.DoubleVar()
        num28_var = tk.DoubleVar()
        num29_var = tk.DoubleVar(value=100)

        #Etiquetas, entry y posicionamiento de la composicion del gas
        etiquetac1 = Label(composicion, text="C1", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetac1.place(x=60,y=90, width=100, height=20)
        valor1 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num1_var)
        valor1.place(x=175, y=90, width=90, height=20)

        etiquetac2 = Label(composicion, text="C2", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetac2.place(x=60,y=110, width=100, height=20)
        valor2 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num2_var)
        valor2.place(x=175, y=110, width=90, height=20)

        etiquetac3 = Label(composicion, text="C3", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetac3.place(x=60,y=130, width=100, height=20)
        valor3 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num3_var)
        valor3.place(x=175, y=130, width=90, height=20)

        etiquetaic4 = Label(composicion, text="i-C4", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetaic4.place(x=60,y=150, width=100, height=20)
        valor4 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num4_var)
        valor4.place(x=175, y=150, width=90, height=20)

        etiquetanc4 = Label(composicion, text="n-C4", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetanc4.place(x=60,y=170, width=100, height=20)
        valor5 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num5_var)
        valor5.place(x=175, y=170, width=90, height=20)

        etiquetaic5 = Label(composicion, text="i-C5", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetaic5.place(x=60,y=190, width=100, height=20)
        valor6 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num6_var)
        valor6.place(x=175, y=190, width=90, height=20)

        etiquetanc5 = Label(composicion, text="n-C5", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetanc5.place(x=60,y=210, width=100, height=20)
        valor7 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num7_var)
        valor7.place(x=175, y=210, width=90, height=20)

        etiquetac6 = Label(composicion, text="C6", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetac6.place(x=60,y=230, width=100, height=20)
        valor8 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num8_var)
        valor8.place(x=175, y=230, width=90, height=20)

        etiquetac7 = Label(composicion, text="C7+", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetac7.place(x=60,y=250, width=100, height=20)
        valor9 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num9_var)
        valor9.place(x=175, y=250, width=90, height=20)

        etiquetah2s = Label(composicion, text="H2S", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetah2s.place(x=60,y=270, width=100, height=20)
        valor10 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num10_var)
        valor10.place(x=175, y=270, width=90, height=20)

        etiquetaco2 = Label(composicion, text="CO2", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetaco2.place(x=60,y=290, width=100, height=20)
        valor11 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num11_var)
        valor11.place(x=175, y=290, width=90, height=20)

        etiquetah2o = Label(composicion, text="H2O", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetah2o.place(x=60,y=310, width=100, height=20)
        valor12 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num12_var)
        valor12.place(x=175, y=310, width=90, height=20)

        etiquetan2 = Label(composicion, text="N2", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetan2.place(x=60,y=330, width=100, height=20)
        valor13 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num13_var)
        valor13.place(x=175, y=330, width=90, height=20)

        etiquetatotal = Label(composicion, text="Total", relief="flat", bg='white', fg="gray26", anchor='center')
        etiquetatotal.place(x=60,y=350, width=100, height=20)
        valor14 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num14_var, state='readonly')
        valor14.place(x=175, y=350, width=90, height=20)
        etiquetaerror = Label(composicion, text="¡Error!", relief="flat", bg='white', fg="red3", anchor='center')
        etiquetaerror.place_forget()

        #Etiquetas y entry de C7+
        etiquetac7 = Label(composicion, text="Propiedades Fracción Pesada (C7+)", bg='white')
        etiquetac7.place(x=40,y=400, width=200, height=30)

        etiquetac7MW = Label(composicion, text="Peso Molecular ", relief="flat", bg='white', fg="gray26", anchor='w')
        etiquetac7MW.place(x=60,y=435, width=100, height=20)
        valor15 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num15_var, state='disabled')
        valor15.place(x=185, y=435, width=90, height=20)

        etiquetac7SG = Label(composicion, text="Gravedad Específica", relief="flat", bg='white', fg="gray26", anchor='w')
        etiquetac7SG.place(x=60,y=460, width=120, height=20)
        valor16 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num16_var, state='disabled')
        valor16.place(x=185, y=460, width=90, height=20)

        #Etiquetas y entry datos de operación
        etiquetadop = Label(composicion, text="Datos de Operación", bg='white')
        etiquetadop.place(x=345,y=30, width=120, height=30)

        etiquetacg = Label(composicion, text="Caudal del Gas ", relief="flat", bg='white', fg="gray26", anchor='w')
        etiquetacg.place(x=365,y=65, width=100, height=20)
        valor17 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num17_var)
        valor17.place(x=520, y=65, width=90, height=20)
        etiquetacgun = Label(composicion, text="MMSCFD", bg='white', fg="gray26", anchor='w')
        etiquetacgun.place(x=620,y=65, width=60, height=20)

        etiquetapres = Label(composicion, text="Presión", relief="flat", bg='white', fg="gray26", anchor='w')
        etiquetapres.place(x=365,y=90, width=100, height=20)
        valor18 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num18_var)
        valor18.place(x=520, y=90, width=90, height=20)
        etiquetaprun = Label(composicion, text="psia", bg='white', fg="gray26", anchor='w')
        etiquetaprun.place(x=620,y=90, width=60, height=20)

        etiquetatemp = Label(composicion, text="Temperatura ", relief="flat", bg='white', fg="gray26", anchor='w')
        etiquetatemp.place(x=365,y=115, width=100, height=20)
        valor19 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num19_var)
        valor19.place(x=520, y=115, width=90, height=20)
        etiquetatgun = Label(composicion, text="°F", bg='white', fg="gray26", anchor='w')
        etiquetatgun.place(x=620,y=115, width=60, height=20)

        etiquetacontco2 = Label(composicion, text="Cont. de CO2 Req.  ", relief="flat", bg='white', fg="gray26", anchor='w')
        etiquetacontco2.place(x=365,y=140, width=105, height=20)
        valor20 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num20_var)
        valor20.place(x=520, y=140, width=90, height=20)
        etiquetaco2un = Label(composicion, text="%V", bg='white', fg="gray26", anchor='w')
        etiquetaco2un.place(x=620,y=140, width=60, height=20)

        etiquetaconth2s = Label(composicion, text="Cont. de H2S Req.  ", relief="flat", bg='white', fg="gray26", anchor='w')
        etiquetaconth2s.place(x=365,y=165, width=105, height=20)
        valor21 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num21_var)
        valor21.place(x=520, y=165, width=90, height=20)
        etiquetah2sun = Label(composicion, text="ppm", bg='white', fg="gray26", anchor='w')
        etiquetah2sun.place(x=620,y=165, width=60, height=20)

        etiquetaDEA = Label(composicion, text="Porcentaje en peso de DEA", relief="flat", bg='white', fg="gray26", anchor='w')
        etiquetaDEA.place(x=365,y=190, width=145, height=20)
        valor22 = ttk.Combobox(composicion, values=[25,35], justify=CENTER, textvariable=num22_var, foreground='blue')
        valor22.place(x=520, y=190, width=100, height=20)
        etiquetaDEAun = Label(composicion, text="%", bg='white', fg="gray26", anchor='w')
        etiquetaDEAun.place(x=630,y=190, width=60, height=20)

        etiquetaamb = Label(composicion, text="Temperatura ambiente", relief="flat", bg='white', fg="gray26", anchor='w')
        etiquetaamb.place(x=365,y=215, width=145, height=20)
        valor29 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num29_var)
        valor29.place(x=520, y=215, width=90, height=20)
        etiquetaambun = Label(composicion, text="°F", bg='white', fg="gray26", anchor='w')
        etiquetaambun.place(x=620,y=215, width=60, height=20)

        #Etiquetas y entry datos de propiedades del gas
        etiquetapge = Label(composicion, text="Propiedades del Gas de entrada", bg='white')
        etiquetapge.place(x=345,y=260+30, width=180, height=30)

        etiquetafljvolrealgas = Label(composicion, text="Flujo Volumétrico Real", relief="flat", bg="white", fg="gray26")
        etiquetafljvolrealgas.place(x=365,y=295+30, width=124, height=20)
        valor23 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num23_var, state='readonly')
        valor23.place(x=520, y=295+30, width=90, height=20)
        etiquetafljvolrealgasu = Label(composicion, text="ft3/hr", relief="flat", bg="white", fg="gray26", anchor='w')
        etiquetafljvolrealgasu.place(x=620,y=295+30, width=50, height=20)

        etiquetafjmasgas = Label(composicion, text="Flujo Másico", relief="flat", bg="white", fg="gray26")
        etiquetafjmasgas.place(x=365,y=320+30, width=73, height=20)
        valor24 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num24_var, state='readonly')
        valor24.place(x=520, y=320+30, width=90, height=20)
        etiquetafjmasgasu = Label(composicion, text="lb/hr", relief="flat", bg="white", fg="gray26", anchor='w')
        etiquetafjmasgasu.place(x=620,y=320+30, width=50, height=20)

        etiquetapemolgas = Label(composicion, text="Peso Molecular", relief="flat", bg="white", fg="gray26")
        etiquetapemolgas.place(x=365,y=345+30, width=86, height=20)
        valor25 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num25_var, state='readonly')
        valor25.place(x=520, y=345+30, width=90, height=20)
        etiquetapemolgasu = Label(composicion, text="lb/lbm", relief="flat", bg="white", fg="gray26", anchor='w')
        etiquetapemolgasu.place(x=620,y=345+30, width=50, height=20)

        etiquetagegas = Label(composicion, text="Gravedad Específica", relief="flat", bg="white", fg="gray26")
        etiquetagegas.place(x=365,y=370+30, width=110, height=20)
        valor26 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num26_var, state='readonly')
        valor26.place(x=520, y=370+30, width=90, height=20)

        etiquetafactzgas = Label(composicion, text="Factor Z", relief="flat", bg="white", fg="gray26")
        etiquetafactzgas.place(x=365,y=395+30, width=50, height=20)
        valor27 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num27_var, state='readonly')
        valor27.place(x=520, y=395+30, width=90, height=20)

        etiquetadengas = Label(composicion, text="Densidad", relief="flat", bg="white", fg="gray26")
        etiquetadengas.place(x=365,y=420+30, width=55, height=20)
        valor28 = Entry(composicion, bg="white", fg="blue", justify=CENTER, textvariable=num28_var, state='readonly')
        valor28.place(x=520, y=420+30, width=90, height=20)
        etiquetadengasu = Label(composicion, text="lb/ft3", relief="flat", bg="white", fg="gray26", anchor='w')
        etiquetadengasu.place(x=620,y=420+30, width=50, height=20)

        # Función de validación para comprobar si el valor introducido es un número
        def validar_numero(valor):
            try:
                float(valor)
                return True
            except ValueError:
                return False
            
        # Configurar validación de los valores de entradas que sean solo numeros
        validacion = composicion.register(validar_numero)
        valor1.config(validate="key", validatecommand=(validacion, '%P'))
        valor2.config(validate="key", validatecommand=(validacion, '%P'))
        valor3.config(validate="key", validatecommand=(validacion, '%P'))
        valor4.config(validate="key", validatecommand=(validacion, '%P'))
        valor5.config(validate="key", validatecommand=(validacion, '%P'))
        valor6.config(validate="key", validatecommand=(validacion, '%P'))
        valor7.config(validate="key", validatecommand=(validacion, '%P'))
        valor8.config(validate="key", validatecommand=(validacion, '%P'))
        valor9.config(validate="key", validatecommand=(validacion, '%P'))
        valor10.config(validate="key", validatecommand=(validacion, '%P'))
        valor11.config(validate="key", validatecommand=(validacion, '%P'))
        valor12.config(validate="key", validatecommand=(validacion, '%P'))
        valor13.config(validate="key", validatecommand=(validacion, '%P'))
        valor14.config(validate="key", validatecommand=(validacion, '%P'))
        valor15.config(validate="key", validatecommand=(validacion, '%P'))
        valor16.config(validate="key", validatecommand=(validacion, '%P'))
        valor17.config(validate="key", validatecommand=(validacion, '%P'))
        valor18.config(validate="key", validatecommand=(validacion, '%P'))
        valor19.config(validate="key", validatecommand=(validacion, '%P'))
        valor20.config(validate="key", validatecommand=(validacion, '%P'))
        valor21.config(validate="key", validatecommand=(validacion, '%P'))
        valor22.config(validate="key", validatecommand=(validacion, '%P'))

        #Funcion para validar la suma de las composicones del gas
        def fnCompGas():
            num1 = num1_var.get()
            num2 = num2_var.get()
            num3 = num3_var.get()
            num4 = num4_var.get()
            num5 = num5_var.get()
            num6 = num6_var.get()
            num7 = num7_var.get()
            num8 = num8_var.get()
            num9 = num9_var.get()
            num10 = num10_var.get()
            num11 = num11_var.get()
            num12 = num12_var.get()
            num13 = num13_var.get()
            etiquetaerror.place_forget()
            btncalcular.configure(state='disabled')
            btndiseño.configure(state='disabled')
            valor15.configure(state=DISABLED)
            valor16.configure(state=DISABLED)

            resultado1 = num1 + num2 + num3 + num4 + num5 + num6 + num7 + num8 + num9 + num10 + num11 + num12 + num13
            num14_var.set(round(resultado1,2))

            if resultado1 == 1:
                valor14.configure(fg="blue")
                if num9 == 0 :
                    valor15.configure(state=DISABLED)
                    valor16.configure(state=DISABLED)
                    btncalcular.configure(state='active')
                else:
                    valor15.configure(state=NORMAL)
                    valor16.configure(state=NORMAL)
                    btncalcular.configure(state='active')

            else:
                valor14.configure(fg="red3")
                etiquetaerror.place(x=270,y=350, width=50, height=20)
                btncalcular.configure(state='disabled')

            valor14.delete(0, 'end')
            valor14.insert(0, round (resultado1,4))

        #Funcion para calcular las propiedades del gas de entrada
        def fnPropGas():
            num1 = num1_var.get()
            num2 = num2_var.get()
            num3 = num3_var.get()
            num4 = num4_var.get()
            num5 = num5_var.get()
            num6 = num6_var.get()
            num7 = num7_var.get()
            num8 = num8_var.get()
            num9 = num9_var.get()
            num10 = num10_var.get()
            num11 = num11_var.get()
            num12 = num12_var.get()
            num13 = num13_var.get()
            num15 = num15_var.get()
            num16 = num16_var.get()
            num17 = num17_var.get()
            num18 = num18_var.get()
            num19 = num19_var.get()+ 459.67
            btndiseño.configure(state='disabled')

        #Temperatura critica c7+
            atcc7=float(544.40)
            btcc7=float(0.299800)
            ctcc7=float(1.05550)
            dtcc7=float(-1.34780*(10**-4))
            etcc7=float(-0.616410)
            ftcc7=float(0)
            TCc7=float(atcc7*(num15**btcc7)*(num16**ctcc7)*exp(dtcc7*num15+etcc7*num16+ftcc7*num15*num16))

            #Presion critica c7+
            apcc7=float(4.52030*(10**4))
            bpcc7=float(-0.806300)
            cpcc7=float(1.60150)
            dpcc7=float(-1.8078*(10**-3))
            epcc7=float(-0.308400)
            fpcc7=float(0)
            PCc7=float(apcc7*(num15**bpcc7)*(num16**cpcc7)*exp(dpcc7*num15+epcc7*num16+fpcc7*num15*num16))
            
            #Temperatura de Ebullición c7+
            atebc7=float(6.77857)
            btebc7=float(0.401673)
            ctebc7=float(-1.58262)
            dtebc7=float(3.77409*(10**-3))
            etebc7=float(2.984036)
            ftebc7=float(-4.25288*(10**-3))
            tempebc7=float(atebc7*(num15**btebc7)*(num16**ctebc7)*exp(dtebc7*num15+etebc7*num16+ftebc7*num15*num16))
            
            #Factor Acéntrico C7+
            kfac7=float((tempebc7**(1/3))/num16)
            tempebrc7=float(tempebc7/TCc7)
            if tempebrc7 >= 0.8:
                Facenc7=float(-7.904+(0.1352*kfac7)-(0.007465*(kfac7**2))+(8.359*tempebrc7)+((1.408-(0.01063*kfac7))/tempebrc7))
            else:
                Facenc7=float((-log((PCc7/14.7))-5.92714+(6.09648/tempebrc7)+(1.28862*log(tempebrc7))-(0.169347*(tempebrc7**6)))/(15.2518-(15.6875/tempebrc7)-(13.4721*log(tempebrc7))+(0.43577*(tempebrc7**6))))
            
            #Se definen las listas donde estaran almacenados los datos 
            FracMolar = [num1, num2, num3, num4, num5, num6, num7, num8, num9, num10, num11, num12, num13]
            PesoMolecular =[16.0429, 30.06990, 44.0970001220703, 58.1240005493164, 58.1240005493164, 72.1510009765625, 72.1510009765625,86.1779022216797, num15, 34.0808982849121, 44.0097007751465, 18.0151004791260, 28.0130004882813]
            TempCri = [-116.411790771484, 90.1004162597657, 206.146418457031, 274.902814941406, 305.688209228516, 369.046418457031, 385.610010986328, 454.546418457031, TCc7, 212.810010986328,87.7100109863282, 705.468220214844, -232.520799560547]
            #lista de temperatura critica en °R
            TempCriRank =[x + 459.67  for x in TempCri]
            PresCri = [673.073579130908, 708.342385308838, 617.376198744141, 529.042432270605, 550.653049570605, 483.496239090454, 489.519659020605, 439.699209070605, PCc7, 1306.46914934854, 1068.92784900000, 3208.23392400000, 492.311634745605]
            acentrico = [0.0114984000101686, 0.0986000001430511, 0.152400001883507,0.184790000319481, 0.201000005006790,0.222240000963211, 0.253890007734299, 0.300700008869171, Facenc7, 0.0810000002384186, 0.238940000534058, 0.344000011682510, 0.0399998016655445]
            Tempred = [num19/x for x in TempCriRank]

            #Calculo del Peso molecular y gravedad especifica del gas natural
            PMgas=0
            for i in range (len(FracMolar)):
                PMgas += FracMolar[i]*PesoMolecular[i]
            num25_var.set(round(PMgas,3))
            num26_var.set(round(PMgas/28.9625 ,3))

            #Peng Robinson EOS
            #Calculo del Primer parametro a
            PengRob_ac = np.zeros(len(FracMolar))
            PengRob_b = np.zeros(len(FracMolar))
            PengRob_alpa = np.zeros(len(FracMolar))
            PengRob_at = np.zeros(len(FracMolar))
            for i in range(len(FracMolar)):
                PengRob_ac[i] = 0.45724 * (10.73**2) * (TempCriRank[i]**2) / PresCri[i]
                PengRob_b[i] = 0.07780 * 10.73 * TempCriRank[i] / PresCri[i]
                PengRob_alpa[i] = (1 + (0.37464 + 1.54226 * acentrico[i] - 0.26992 * (acentrico[i]**2))*(1 - (Tempred[i]**0.5)))**2
                PengRob_at[i] = PengRob_ac[i]*PengRob_alpa[i]
            
            #Calculo de la constante de mezcla de peng robinson b
            PengRob_Bt=0
            for i in range (len(FracMolar)):
                PengRob_Bt += FracMolar[i]*PengRob_b[i]

            #Calculo de la constante de mezcla de peng robinson at
            PengRob_att=0
            for i in range (len(FracMolar)):
                for j in range (len(FracMolar)):
                    PengRob_att += FracMolar[i]*FracMolar[j]*((PengRob_at[i]*PengRob_at[j])**0.5)

            #Calculo de A para la EOS de PR
            Azpr = PengRob_att*num18/((10.73**2)*(num19**2))
            #Calculo de B para la EOS de PR
            Bzpr = PengRob_Bt * num18 /(10.73 * num19)

            #Cálculo de Z
            Zasumida=1
            diferenciaZ=float(1)
            factorZ=float()
            contadorz = float(0)
            while contadorz < 10:
                FuncionZ=float((Zasumida**3)-((1-Bzpr)*(Zasumida**2))+((Azpr-(3*(Bzpr**2))-(2*Bzpr))*Zasumida)-((Azpr*Bzpr)-(Bzpr**2)-(Bzpr**3)))
                DerivadAzpr=float((3*(Zasumida**2))-(2*(1-Bzpr)*Zasumida)+((Azpr-(3*(Bzpr**2))-(2*Bzpr))))
                NuevAzpr=float(Zasumida-(FuncionZ/DerivadAzpr))
                diferenciaZ=float(Zasumida-NuevAzpr)
                Zasumida=float(NuevAzpr)
                contadorz+=1
            factorZ=float(Zasumida)
            num27_var.set(round(factorZ ,3))

            #Cálculo de la densidad del gas
            densidadgas=float(((num18)*PMgas)/(factorZ*10.73*(num19)))
            num28_var.set(round(densidadgas,3))
            
            #Cálculo del Flujo Volumétrico Real
            Qrealgas=float((41666.66*factorZ*num17*(num19)*14.7)/((32+459.67)*(num18)))
            num23_var.set(round(Qrealgas,3))

            #Cálculo del Fujo Másico del Gas
            Flujmasgas=float(Qrealgas*densidadgas)
            num24_var.set(round(Flujmasgas,3))

            btndiseño.configure(state='active')


        #Botón suma de las fracciones molares
        btnsuma = Button(composicion, text="Sumar", bg="white", command=fnCompGas)
        btnsuma.place(x=190, y=375, width=60, height=25)

        #Botón scalcula las propiedades del gas natual
        btncalcular = Button(composicion, text="Calcular", bg="white", command=fnPropGas, state='disabled')
        btncalcular.place(x=535, y=245, width=60, height=25)

        class CalculadoraDEA:
            def __init__(self):
                # Aquí puedes inicializar cualquier atributo necesario
                pass

            def leer_datos(self):
                #Definir las variables de entrada
                self.Qg = num17_var.get() #flujo de gas en mmscfd
                self.GEg= num26_var.get() #GRavedad especifica de gas
                self.Pgi=num18_var.get() #Presion del gas en la entrada psig
                self.Tgi=num19_var.get() #TEmperatura del gas en la entrada F
                self.Yco2i=num11_var.get()*100 #Contenido de CO2 en el gas de entrada %
                self.Yco2o=num20_var.get() #Contenido de CO2 en el gas de salida %
                self.Yh2si= num10_var.get()*100#Contenido de H2S en el gas de entrada %
                self.Yh2so=num21_var.get()/10000 #Contenido de H2S en el gas de salida %
                self.Tamb= num29_var.get() #Temperatura maxima del ambiente F
                self.Camina=num22_var.get()/100 #Fraccion en peso de la amina
                self.Dsolucion=8.71 #Densidad de la DEA lpg
                self.AL=0.5 #Carga de gas acido moles gas acido/moles amina
                self.Vm=379.5 #Volumen de una lbmol de gas a SC
                concentracion=self.Camina*100
                self.CpDEA = -0.000022688*(concentracion**2) - 0.00174*concentracion + 1.0024 #Calor especifico DEA  BTU/lb-F
            
            def calcular_tasa_circulacion(self):
                #Calcular la tasa de circulacion de la DEA 
                Xa=(self.Yco2i+self.Yh2si)/100 #Reduccion requerida de gas acido
                numerador=192*self.Qg*Xa
                denominador=self.Camina*self.Dsolucion*self.AL
                Ldea=numerador/denominador #Tasa circulacion de la DEA gpm
                Ldea1=Ldea*1.1
                return round(Ldea1) #gpm

            def Mol_CO2_abs(self):
                #calcular las moles de CO2 absorbidas
                Xa=(self.Yco2i+self.Yh2si)/100
                nco2=round(self.Qg*1000000*Xa/self.Vm) #redondeo al siguiente entero
                return nco2 #lbmolco2/dia

            def Mol_DEA_cir(self):
                #Calcular las moles de DEA Circuladas
                LDEA= self.calcular_tasa_circulacion()
                DensidadDEA=self.Dsolucion
                FraccionpesoDEA=self.Camina
                MDEA=105.14 #Peso molecular de la DEA lbDEA/lbmolDEA
                nDEA=LDEA*DensidadDEA*FraccionpesoDEA*1440/MDEA+10-((LDEA*DensidadDEA*FraccionpesoDEA*1440/MDEA)%10) #redondeo al multiplo de 10 superior
                return nDEA #lbmolDEA/dia
            
            def RelacionMolarCO2DEA (self):
                # Calcular la relacion molar co2/DEA
                nco2=self.Mol_CO2_abs()
                nDEA=self.Mol_DEA_cir()
                RM=nco2/nDEA+0.01-((nco2/nDEA)%0.01) #redondeo al multiplo de 0.01 superior
                return RM #lbmolco2/lbmolDEA

            def DutyReaccionCO2 (self):
                #Calcular el duty de reaccion debido al CO2 
                RM= self.RelacionMolarCO2DEA()
                nco2=self.Mol_CO2_abs()
                concentracion = self.Camina
                if concentracion == 0.35:
                    DeltH = round(1750*(RM**3)-2577.381*(RM**2)+517.381*RM+729.6) #Calor de reaccion debido al CO2 leido de tablas
                elif concentracion == 0.25:
                    DeltH = round(1250*(RM**3) - 1887.5*(RM**2) + 332.5*RM + 684)
                Mco2=44 #peso molecularcdel co2 lb/mol
                Q_reaccion=DeltH*Mco2*nco2/24 #Duty de reaccion debido al co2 BTU/h
                Q_reaccion_MMBTU=round(Q_reaccion/1000000, 2)#redondeo a 2 cifras 
                return Q_reaccion_MMBTU #MMBTU/h

            def Mol_H2S_abs(self):
                #calcular las moles de H2S absorbidas
                nh2s=round(self.Qg*1000000*((self.Yh2si-self.Yh2so)/100)/self.Vm) #redondeo al siguienete entero
                return nh2s #lbmolh2s/dia

            def RelacionMolarH2SDEA (self):
                # Calcular la relacion molar H2S/DEA
                nh2s=self.Mol_H2S_abs()
                nDEA=self.Mol_DEA_cir()
                RM=round(nh2s/nDEA,5) #redondeo a 5 cifras significativas
                return RM #lbmolh2s/lbmolDEA

            def DutyReaccionH2S (self):
                #Calcular el duty de reaccion debido al H2S MMBTU/h
                RM= self.RelacionMolarH2SDEA()
                nh2s=self.Mol_H2S_abs()
                if nh2s <= 0.2:
                    DeltH= 604
                elif 0.2 < RM < 1.4:
                    DeltH = -14960*(RM**6) + 66438*(RM**5) - 113246*(RM**4) + 93653*(RM**3) - 39497*(RM**2) + 7783*RM + 38.234 #Calor de reaccion debido al H2S leido de tablas
                else:
                    DeltH = 139
                Mh2s=34 #peso molecularcdel h2s lb/mol
                Q_reaccion=DeltH*Mh2s*nh2s/24 #Duty de reaccion debido al h2s BTU/h
                Q_reaccion_MMBTU=Q_reaccion/1000000
                return round(Q_reaccion_MMBTU,2) #MMBTU/h redondeo a 2 cifras

            def DutyGas(self):
                #Duty ganado por el gas MMBTU/h 
                TDEAi=self.Tgi+10 #Temperatura de entrada de la DEA F
                T2gTDEA1=5 #aproach entre T2g y TDEA1
                T2g=TDEAi+T2gTDEA1 #Temperatura de salida gas en el contactor
                Cpg=0.65 #Calor especifico del gas
                Mg=self.GEg*28.96 #Peso molecular del gas
                fmg=self.Qg*1000000*Mg/self.Vm/24 #Flujo masico del gas
                fqg=fmg*Cpg*(T2g-self.Tgi)#Duty gganado por el gas BTU/h
                return round(fqg/1000000,2) #MMBTU/h
                
            def Dutyatmosfera(self):
                #Calcular el duty perdido hacia la atmosfera
                qrco2=self.DutyReaccionCO2()
                qrh2s=self.DutyReaccionH2S()
                qloss=0.05*(qrco2+qrh2s)
                return round(qloss,2) #MMBTU/h redondeo a 2 cifras

            def DutyDEA(self):
                #Calcular el duty ganado por la DEA
                qrco2=self.DutyReaccionCO2()
                qrh2s=self.DutyReaccionH2S()
                qloss=self.Dutyatmosfera()
                qg=self.DutyGas()
                qDEA=qrco2+qrh2s-qg-qloss
                return round(qDEA,2) #MMBTU/h redondeo a 2 cifras

            def Tem_sal_DEA (self):
                #Calcular la temperatura de salida de la DEA en el contactor
                ldea=self.calcular_tasa_circulacion() #gpm
                densi_DEA=self.Dsolucion #Densidad de la DEA lb/gal
                TDEAi=self.Tgi+10 #Temperatura de entrada de la DEA F
                cpDEA=0.92 #Calor especifico DEA BTU/lb-F
                qDEA=self.DutyDEA()
                mDEA=ldea*densi_DEA*60 #Flujo masico de DEA lb/h
                T2DEA=qDEA*1000000/(mDEA*cpDEA)+TDEAi
                return round(T2DEA,2) #F 

            def Dutyrehervidor(self):
                #Calcular el duty del rehervidor
                ldea=self.calcular_tasa_circulacion() #gpm
                qreb=60000*ldea/1000000 
                return round(qreb,3) #MMBTU/h

            def Tout_leanamineHX(self):
                #Calcular temperatura de salida de la amina pobre 
                TinleanDEA=250 #Temperatura de entrada de la amina pobre al HX
                TinrichDEA=self.Tem_sal_DEA ()#Temperatura de entrada de la amina rica al HX
                DeltaTapro=30 #Temperatura de approach
                ToutrichDEA=TinleanDEA-DeltaTapro #Temperatura salida amina rica del HX
                ldea=self.calcular_tasa_circulacion()
                Dens_DEA=self.Dsolucion #densidad de la DEA
                mleanDEA=60*ldea*Dens_DEA #flujo masico amina pobre lb/h
                nco2abs=self.Mol_CO2_abs()
                Mco2=44 #peso molecular del co2 lb/mol
                nh2sabs=self.Mol_H2S_abs()
                Mh2s=34 #peso molecularcdel h2s lb/mol
                mco2=nco2abs*Mco2/24 #flujo masico co2 en amina rica lb/h
                mh2s=nh2sabs*Mh2s/24 #flujo masico h2s en amina rica lb/h
                mrichDEA=mleanDEA+mco2+mh2s #flujo masico amina rica lb/h
                ToutleanDEA=TinleanDEA-((ToutrichDEA-TinrichDEA)*(mrichDEA/mleanDEA))
                return round(ToutleanDEA,2) #F

            def Duty_HX(self):
                #Calcular el duty del intercambiador amina rica/amina pobre
                CpDEA = self.CpDEA #Calor especifico DEA  BTU/lb-F
                ldea=self.calcular_tasa_circulacion()
                Dens_DEA=self.Dsolucion #densidad de la DEA
                mleanDEA=60*ldea*Dens_DEA #flujo masico amina pobre lb/h
                ToutleanDEA=self.Tout_leanamineHX()
                TinleanDEA=250
                qleanDEA=mleanDEA*CpDEA*(ToutleanDEA-TinleanDEA)/1000000
                return round(-qleanDEA,2)

            def Duty_cooler(self):
                #Calcular el duty del enfriador de la amina pobre
                TDEAi=self.Tgi+10 #Temperatura de entrada de la DEA F
                ToutleanDEA=self.Tout_leanamineHX()
                CpDEA = self.CpDEA #Calor especifico DEA  BTU/lb-F
                ldea=self.calcular_tasa_circulacion()
                Dens_DEA=self.Dsolucion #densidad de la DEA
                mleanDEA=60*ldea*Dens_DEA #flujo masico amina pobre lb/h
                qcooler=mleanDEA*CpDEA*(ToutleanDEA-TDEAi)/1000000
                return round(qcooler,2) #MMBTU/h
                
            def PresionParcial(self,x):
                #Devuelve la presion parcial del agua x(F) temperatura del condensador
                # temp=(32,35,40,45,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190) #tupla de temperatura de agua 
                # PP=(0.08854,0.09995,0.12170,0.14752,0.17811,0.2563,0.3631,0.5069,0.6982,0.9492,1.2748,1.6924,2.2225,2.3886,3.718,4.741,5.992,7.510,9.339) #Presion parcial del agua @T
                # index=temp.index(x)
                # PresionP=PP[index]
                if x>32 and x<190:
                    pparcial= 1.269E-08*(x**4) - 1.896E-06*(x**3) + 1.690E-04*(x**2) - 1.298E-03*x - 1.176E-02
                else:
                    pparcial=9.339
                return (round(pparcial,2)) #psia
            
            def Vapor_acido(self):
                #Calcular Flujo de vapor de agua que sale del condensador
                Temp_amb=self.Tamb #Temperatura del ambiente F
                DeltaT_cond= 30 #Approach en el condensador F
                Tem_cooler=Temp_amb+DeltaT_cond
                Pr=10 #Presion del acumulador de reflujo se asume 10 psig
                nco2=self.Mol_CO2_abs()
                nh2s=self.Mol_H2S_abs()
                AG=nco2+nh2s #Flujo molar carga acida
                Vol_molar=self.Vm
                PPh2o=self.PresionParcial(Tem_cooler) #Presion parcial de agua a Tcooler
                Vr=((Pr+14.7)*AG)/((Pr+14.7)-PPh2o) #flujo molar de vapor acido que sale del condensador lbmol/d

                return round(Vr,2) #lbmol/d
                
            def Vapor_despojo(self):
                #Calcular Flujo de vapor de agua que sale del condensador
                Temp_amb=self.Tamb #Temperatura del ambiente F
                DeltaT_cond= 30 #Approach en el condensador F
                Tem_cooler=Temp_amb+DeltaT_cond
                Pr=10 #Presion del acumulador de reflujo se asume 10 psig
                nco2=self.Mol_CO2_abs()
                nh2s=self.Mol_H2S_abs()
                AG=nco2+nh2s #Flujo molar carga acida
                Vol_molar=self.Vm
                PPh2o=self.PresionParcial(Tem_cooler) #Presion parcial de agua a Tcooler
                Vr=((Pr+14.7)*AG)/((Pr+14.7)-PPh2o) #flujo molar de vapor acido que sale del condensador lbmol/d
                Vr_MMSCFD=Vr*Vol_molar/1000000 #flujo vapor acido que sale del condensador en MMSCFD
                Vh2o=(Vr-nco2-nh2s)*18*Vol_molar #Flujo volumetrico de vapor de agua que sale del condensador lb/d
                return round(Vh2o/1000000,2) #lb/h

            def Duty_condensador(self):
                #Calcular el Duty del condensador
                qrco2=self.DutyReaccionCO2()
                qrh2s=self.DutyReaccionH2S()
                qreh=self.Dutyrehervidor()
                ldea=self.calcular_tasa_circulacion()
                Dens_DEA=self.Dsolucion #densidad de la DEA
                mleanDEA=60*ldea*Dens_DEA #flujo masico amina pobre lb/h
                CpDEA=self.CpDEA #Calor especifico DEA  BTU/lb-F
                Toutreh=250 #Temperatura amina que sale del rehervidor es la misma Temperatura de entrada de la amina pobre al intercambiador 
                DeltaTapro=30 #Temperatura de approach
                Tinreh=Toutreh-DeltaTapro #Temperatura entrada amina rica al rehervidor es la misma Temperatura de salida de la amina rica del intercambiador
                qleanDEA=mleanDEA*CpDEA*(Toutreh-Tinreh)/1000000
                qcond=qreh-qleanDEA-qrco2-qrh2s
                return round(qcond ,3)

            def reflujo(self):
                Ttoptray=210 #Temperatura del plato del tope
                Tcond=130 #TEmperatura del Condensador
                AG=self.Mol_H2S_abs() + self.Mol_CO2_abs() #Fljo molar del gas acida
                CPg=0.65 #calor especifico del gas
                q_g=AG/24*44*CPg*(Ttoptray-Tcond) #duty para enfriar el gas acido
                qcond=self.Duty_condensador()*1000000 #duty condensador
                hs=1149.5 #entalpia del vapor a Ttoptray
                hl=180 #entalpia agua a Tcond
                WR=(qcond-q_g)/(hs-hl) #tasa reflujo de agua
                Vtop= AG+(WR+self.Vapor_despojo())/18*24 #Flujo molar vapor que sale en el TopTray  lbmol/d
                WW=Vtop-AG #Flujo molar agua en el plato del tope
                PPH2O=WW*24.7/(Vtop)
                return PPH2O
            
            
        def ventana_planta():
            #Configurar la ventana. Titulo, tamaño y color de fondo
            planta1=Toplevel()
            planta1.title("Planta de endulzamiento de gas natural - Diseño")
            planta1.geometry("1020x620+190+40")
            planta1.configure(bg='#f0f0f0')
            #Permite que el usuario no maximice la pagina
            planta1.resizable(0,0)

            #Líneas Verticales y Horizontales
            #linea Vertical Izquierda
            lvi=Label(planta1, relief="groove")
            lvi.place(x=10, y=10, width=2, height=600)
            #linea Vertical Derecha
            lvd=Label(planta1, relief="groove")
            lvd.place(x=1010, y=10, width=2, height=600)
            #linea Horizontal Superior
            lhs=Label(planta1, relief="groove")
            lhs.place(x=10, y=10, width=1000, height=2)    
            #linea Horizontal Inferior
            lhi=Label(planta1, relief="groove")
            lhi.place(x=10, y=610, width=1000, height=2)


            # Carga la imagen de fondo
            imagen = Image.open("Imagen2.png")
            imagen = imagen.resize((1000, 600), Image.LANCZOS)
            fondo_imagen = ImageTk.PhotoImage(imagen)
            # Establece la imagen de fondo
            background_label1 = Label(planta1, image=fondo_imagen)
            background_label1.place(x=10, y=10)

            def ventana_absorbedor():
                calculadora=CalculadoraDEA()
                #Configurar la ventana. Titulo, tamaño y color de fondo
                tabsorcion=Toplevel()
                tabsorcion.title("Balance de energia en la torre de absorción")
                tabsorcion.geometry("760x520+340+50")
                tabsorcion.configure(bg='white')
                #Permite que el usuario no maximice la pagina
                tabsorcion.resizable(0,0)

                #Líneas Verticales y Horizontales
                #linea Vertical Izquierda
                lvi=Label(tabsorcion, relief="groove")
                lvi.place(x=10, y=10, width=2, height=500)
                #linea Vertical Derecha
                lvd=Label(tabsorcion, relief="groove")
                lvd.place(x=750, y=10, width=2, height=500)
                #linea Vertical media
                lvm=Label(tabsorcion, relief="groove")
                lvm.place(x=360, y=20, width=2, height=480)
                #linea Horizontal Superior
                lhs=Label(tabsorcion, relief="groove")
                lhs.place(x=10, y=10, width=740, height=2)    
                #linea Horizontal Inferior
                lhi=Label(tabsorcion, relief="groove")
                lhi.place(x=10, y=510, width=740, height=2)
                #linea Horizontal media
                lhm=Label(tabsorcion, relief="groove")
                lhm.place(x=370, y=450, width=370, height=2)

                # Carga la imagen del equipo
                imagen = Image.open("absorbedor.png")
                imagen = imagen.resize((262, 440), Image.LANCZOS)
                fondo_imagen = ImageTk.PhotoImage(imagen)
                # Establece la imagen del equipo
                background_label1 = Label(tabsorcion, image=fondo_imagen, anchor='center', borderwidth=2, relief='groove', background='white')
                background_label1.place(x=50, y=40)

                num1_var = tk.DoubleVar(value=0)
                num2_var = tk.DoubleVar(value=0)
                num3_var = tk.DoubleVar(value=0)
                num4_var = tk.DoubleVar(value=0)
                num5_var = tk.DoubleVar(value=0)
                num6_var = tk.DoubleVar(value=0)
                num7_var = tk.DoubleVar(value=0)
                num8_var = tk.DoubleVar(value=0)

                #Etiquetas, entry y posicionamiento de la tabsorcion del gas
                etiqueta0 = Label(tabsorcion, text="Balance de energia en la torre de absorción", relief="flat", bg='white', anchor='w')
                etiqueta0.place(x=390,y=50, width=270,  height=30)
                
                #Etiquetas, entry y posicionamiento de la tabsorcion del gas
                etiqueta1 = Label(tabsorcion, text="Tasa circulación DEA", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta1.place(x=400,y=90, width=170,  height=20)
                valor1 = Entry(tabsorcion, bg="white", fg="blue", justify=CENTER, textvariable=num1_var)
                valor1.place(x=580, y=90, width=80, height=20)
                etiqueta1u = Label(tabsorcion, text="USGPM", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta1u.place(x=670,y=90, width=50,  height=20)
                
                etiqueta2 = Label(tabsorcion, text="Tasa circulación seguridad DEA", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta2.place(x=400,y=130, width=170,  height=20)
                valor2 = Entry(tabsorcion, bg="white", fg="blue", justify=CENTER, textvariable=num2_var)
                valor2.place(x=580, y=130, width=80, height=20)
                etiqueta2u = Label(tabsorcion, text="USGPM", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta2u.place(x=670,y=130, width=50,  height=20)

                etiqueta3 = Label(tabsorcion, text="Duty de reacción al CO2", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta3.place(x=400,y=170, width=170,  height=20)
                valor3 = Entry(tabsorcion, bg="white", fg="blue", justify=CENTER, textvariable=num3_var)
                valor3.place(x=580, y=170, width=80, height=20)
                etiqueta3u = Label(tabsorcion, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta3u.place(x=670,y=170, width=70,  height=20)

                etiqueta4 = Label(tabsorcion, text="Duty de reacción al H2S", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta4.place(x=400,y=210, width=170,  height=20)
                valor4 = Entry(tabsorcion, bg="white", fg="blue", justify=CENTER, textvariable=num4_var)
                valor4.place(x=580, y=210, width=80, height=20)
                etiqueta4u = Label(tabsorcion, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta4u.place(x=670,y=210, width=70,  height=20)

                etiqueta5 = Label(tabsorcion, text="Duty ganado por el gas", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta5.place(x=400,y=250, width=170,  height=20)
                valor5 = Entry(tabsorcion, bg="white", fg="blue", justify=CENTER, textvariable=num5_var)
                valor5.place(x=580, y=250, width=80, height=20)
                etiqueta5u = Label(tabsorcion, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta5u.place(x=670,y=250, width=70,  height=20)

                etiqueta6 = Label(tabsorcion, text="Duty perdido hacia la atmosfera", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta6.place(x=400,y=290, width=170,  height=20)
                valor6 = Entry(tabsorcion, bg="white", fg="blue", justify=CENTER, textvariable=num6_var)
                valor6.place(x=580, y=290, width=80, height=20)
                etiqueta6u = Label(tabsorcion, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta6u.place(x=670,y=290, width=70,  height=20)

                etiqueta7 = Label(tabsorcion, text="Duty ganado por la DEA", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta7.place(x=400,y=330, width=170,  height=20)
                valor7 = Entry(tabsorcion, bg="white", fg="blue", justify=CENTER, textvariable=num7_var)
                valor7.place(x=580, y=330, width=80, height=20)
                etiqueta7u = Label(tabsorcion, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta7u.place(x=670,y=330, width=70,  height=20)

                etiqueta8 = Label(tabsorcion, text="Temperatura de salida DEA", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta8.place(x=400,y=370, width=170,  height=20)
                valor8 = Entry(tabsorcion, bg="white", fg="blue", justify=CENTER, textvariable=num8_var)
                valor8.place(x=580, y=370, width=80, height=20)
                etiqueta8u = Label(tabsorcion, text="°F", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta8u.place(x=670,y=370, width=40,  height=20)

                calculadora.leer_datos()
                num1_var.set(round(calculadora.calcular_tasa_circulacion()/1.1))
                num2_var.set(calculadora.calcular_tasa_circulacion())
                num3_var.set(calculadora.DutyReaccionCO2())
                num4_var.set(calculadora.DutyReaccionH2S())
                num5_var.set(calculadora.DutyGas())
                num6_var.set(calculadora.Dutyatmosfera())
                num7_var.set(calculadora.DutyDEA())
                num8_var.set(calculadora.Tem_sal_DEA())


                def ir_atras():
                    tabsorcion.withdraw()

                boton1 = Button(tabsorcion, text='Atras', command=ir_atras)
                boton1.place(x=640,y=470, width=90, height=25)
                
                tabsorcion.mainloop()

            # Carga la imagen de absorbedora
            imagenabs = Image.open("Imagen3.png")
            absorbedora = ImageTk.PhotoImage(imagenabs)
            # Establece la imagen de la torre absorbedora como un boton
            botton_imagen1 = Button(planta1, image=absorbedora, borderwidth=1, command=ventana_absorbedor, highlightcolor='blue')
            botton_imagen1.place(x=167, y=137)

            def ventana_intercambiador():
                calculadora=CalculadoraDEA()
                #Configurar la ventana. Titulo, tamaño y color de fondo
                intercambiador=Toplevel()
                intercambiador.title("Diseño del intercambiador amina pobre/amina rica")
                intercambiador.geometry("780x410+340+100")
                intercambiador.configure(bg='white')
                #Permite que el usuario no maximice la pagina
                intercambiador.resizable(0,0)

                #Líneas Verticales y Horizontales
                #linea Vertical Izquierda
                lvi=Label(intercambiador, relief="groove")
                lvi.place(x=10, y=10, width=2, height=390)
                #linea Vertical Derecha
                lvd=Label(intercambiador, relief="groove")
                lvd.place(x=770, y=10, width=2, height=390)
                #linea Vertical media
                lvm=Label(intercambiador, relief="groove")
                lvm.place(x=360, y=20, width=2, height=370)
                #linea Horizontal Superior
                lhs=Label(intercambiador, relief="groove")
                lhs.place(x=10, y=10, width=760, height=2)    
                #linea Horizontal Inferior
                lhi=Label(intercambiador, relief="groove")
                lhi.place(x=10, y=400, width=760, height=2)
                #linea Horizontal media
                lhm=Label(intercambiador, relief="groove")
                lhm.place(x=370, y=340, width=390, height=2)

                # Carga la imagen del equipo
                imagen = Image.open("intercambiador11.png")
                imagen = imagen.resize((310, 270), Image.LANCZOS)
                fondo_imagen = ImageTk.PhotoImage(imagen)
                # Establece la imagen del equipo
                equipo_intercambiador = Label(intercambiador, image=fondo_imagen, anchor='center', borderwidth=2, relief='groove', background='white')
                equipo_intercambiador.place(x=30, y=70, width=310, height=270)

                num1_var = tk.DoubleVar(value=0)
                num2_var = tk.DoubleVar(value=0)
                num3_var = tk.DoubleVar(value=0)
                num4_var = tk.DoubleVar(value=0)
                num5_var = tk.DoubleVar(value=0)
                num6_var = tk.DoubleVar(value=0)
                num7_var = tk.DoubleVar(value=0)
                num8_var = tk.DoubleVar(value=0)
                num9_var = tk.DoubleVar(value=0)
                num10_var = tk.DoubleVar(value=0)

                #Etiquetas, entry y posicionamiento de la intercambiador del gas
                etiqueta0 = Label(intercambiador, text="Cálculo del Duty del intercambiador", relief="flat", bg='white', anchor='w')
                etiqueta0.place(x=380,y=40, width=270,  height=30)

                #Etiquetas, entry y posicionamiento de la intercambiador del gas
                etiqueta1 = Label(intercambiador, text="Temperatura entrada DEA pobre al IC", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta1.place(x=390, y=80, width=200,  height=20)
                valor1 = Entry(intercambiador, bg="white", fg="blue", justify=CENTER, textvariable=num1_var, state='readonly')
                valor1.place(x=610, y=80, width=80, height=20)
                etiqueta1u = Label(intercambiador, text="°F", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta1u.place(x=700,y=80, width=70,  height=20)

                etiqueta2 = Label(intercambiador, text="Temperatura entrada DEA rica al IC", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta2.place(x=390,y=105, width=200,  height=20)
                valor2 = Entry(intercambiador, bg="white", fg="blue", justify=CENTER, textvariable=num2_var, state='readonly')
                valor2.place(x=610, y=105, width=80, height=20)
                etiqueta2u = Label(intercambiador, text="°F", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta2u.place(x=700,y=105, width=70,  height=20)

                etiqueta3 = Label(intercambiador, text="ΔT amina pobre/amina rica", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta3.place(x=390,y=130, width=200,  height=20)
                valor3 = Entry(intercambiador, bg="white", fg="blue", justify=CENTER, textvariable=num3_var, state='readonly')
                valor3.place(x=610, y=130, width=80, height=20)
                etiqueta3u = Label(intercambiador, text="°F", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta3u.place(x=700,y=130, width=70,  height=20)

                etiqueta4 = Label(intercambiador, text="Tasa de circulación DEA", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta4.place(x=390,y=155, width=200,  height=20)
                valor4 = Entry(intercambiador, bg="white", fg="blue", justify=CENTER, textvariable=num4_var, state='readonly')
                valor4.place(x=610, y=155, width=80, height=20)
                etiqueta4u = Label(intercambiador, text="USGPM", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta4u.place(x=700,y=155, width=70,  height=20)

                etiqueta5 = Label(intercambiador, text="Flujo másico DEA pobre", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta5.place(x=390,y=180, width=200,  height=20)
                valor5 = Entry(intercambiador, bg="white", fg="blue", justify=CENTER, textvariable=num5_var, state='readonly')
                valor5.place(x=610, y=180, width=80, height=20)
                etiqueta5u = Label(intercambiador, text="lb/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta5u.place(x=700,y=180, width=70,  height=20)

                etiqueta6 = Label(intercambiador, text="Moles de H2S absorbidas", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta6.place(x=390,y=205, width=200,  height=20)
                valor6 = Entry(intercambiador, bg="white", fg="blue", justify=CENTER, textvariable=num6_var, state='readonly')
                valor6.place(x=610, y=205, width=80, height=20)
                etiqueta6u = Label(intercambiador, text="lbmol/d", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta6u.place(x=700,y=205, width=70,  height=20)

                etiqueta7 = Label(intercambiador, text="Moles de CO2 absorbidas", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta7.place(x=390,y=230, width=200,  height=20)
                valor7 = Entry(intercambiador, bg="white", fg="blue", justify=CENTER, textvariable=num7_var, state='readonly')
                valor7.place(x=610, y=230, width=80, height=20)
                etiqueta7u = Label(intercambiador, text="lbmol/d", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta7u.place(x=700,y=230, width=70,  height=20)

                etiqueta8 = Label(intercambiador, text="Flujo másico DEA rica", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta8.place(x=390,y=255, width=200,  height=20)
                valor8 = Entry(intercambiador, bg="white", fg="blue", justify=CENTER, textvariable=num8_var, state='readonly')
                valor8.place(x=610, y=255, width=80, height=20)
                etiqueta8u = Label(intercambiador, text="lb/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta8u.place(x=700,y=255, width=70,  height=20)

                etiqueta9 = Label(intercambiador, text="Temperatura salida DEA pobre del IC", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta9.place(x=390,y=280, width=200,  height=20)
                valor9 = Entry(intercambiador, bg="white", fg="blue", justify=CENTER, textvariable=num9_var, state='readonly')
                valor9.place(x=610, y=280, width=80, height=20)
                etiqueta9u = Label(intercambiador, text="°F", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta9u.place(x=700,y=280, width=70,  height=20)

                etiqueta10 = Label(intercambiador, text="Duty IC amina rica/amina pobre", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta10.place(x=390,y=305, width=200,  height=20)
                valor10 = Entry(intercambiador, bg="white", fg="blue", justify=CENTER, textvariable=num10_var, state='readonly')
                valor10.place(x=610, y=305, width=80, height=20)
                etiqueta10u = Label(intercambiador, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta10u.place(x=700,y=305, width=70,  height=20)

                calculadora.leer_datos()
                num1_var.set(value=250)
                num2_var.set(calculadora.Tem_sal_DEA())
                num3_var.set(value=30)
                num4_var.set(calculadora.calcular_tasa_circulacion())
                var1=calculadora.calcular_tasa_circulacion()*60*8.71
                num5_var.set(round(var1))
                num6_var.set(calculadora.Mol_H2S_abs())
                num7_var.set(calculadora.Mol_CO2_abs())
                num8_var.set(round(num5_var.get()+(num6_var.get()*34/24)+(num7_var.get()*44/24)))
                num9_var.set(calculadora.Tout_leanamineHX())
                num10_var.set(calculadora.Duty_HX())


                def ir_atras1():
                    intercambiador.withdraw()


                boton1 = Button(intercambiador, text='Atras', command=ir_atras1)
                boton1.place(x=660,y=360, width=90, height=25)

                intercambiador.mainloop()

            # Carga la imagen de intercambiador
            imagenhe= Image.open("Imagen5.png")
            HeatEX = ImageTk.PhotoImage(imagenhe)
            # Establece la imagen del intercambiador como un boton
            botton_imagen3 = Button(planta1, image=HeatEX, borderwidth=1, command=ventana_intercambiador, highlightcolor='blue')
            botton_imagen3.place(x=540, y=446)

            def ventana_rehervidor():
                calculadora=CalculadoraDEA()
                #Configurar la ventana. Titulo, tamaño y color de fondo
                rehervidor=Toplevel()
                rehervidor.title("Diseño del rehervidor")
                rehervidor.geometry("760x350+340+100")
                rehervidor.configure(bg='white')
                #Permite que el usuario no maximice la pagina
                rehervidor.resizable(0,0)

                #Líneas Verticales y Horizontales
                #linea Vertical Izquierda
                lvi=Label(rehervidor, relief="groove")
                lvi.place(x=10, y=10, width=2, height=330)
                #linea Vertical Derecha
                lvd=Label(rehervidor, relief="groove")
                lvd.place(x=750, y=10, width=2, height=330)
                #linea Vertical media
                lvm=Label(rehervidor, relief="groove")
                lvm.place(x=360, y=20, width=2, height=310)
                #linea Horizontal Superior
                lhs=Label(rehervidor, relief="groove")
                lhs.place(x=10, y=10, width=740, height=2)    
                #linea Horizontal Inferior
                lhi=Label(rehervidor, relief="groove")
                lhi.place(x=10, y=340, width=740, height=2)
                #linea Horizontal media
                lhm=Label(rehervidor, relief="groove")
                lhm.place(x=370, y=280, width=370, height=2)

                # Carga la imagen del equipo
                imagen = Image.open("Rehervidor11.png")
                imagen = imagen.resize((310, 270), Image.LANCZOS)
                fondo_imagen = ImageTk.PhotoImage(imagen)
                # Establece la imagen del equipo
                equipo_rehervidor = Label(rehervidor, image=fondo_imagen, anchor='center', borderwidth=2, relief='groove', background='white')
                equipo_rehervidor.place(x=30, y=40, width=310, height=270)

                num1_var = tk.DoubleVar(value=0)
                num2_var = tk.DoubleVar(value=0)

                #Etiquetas, entry y posicionamiento de la rehervidor del gas
                etiqueta0 = Label(rehervidor, text="Cálculo del Duty del rehervidor", relief="flat", bg='white', anchor='w')
                etiqueta0.place(x=390,y=50, width=270,  height=30)

                #Etiquetas, entry y posicionamiento de la rehervidor del gas
                etiqueta4 = Label(rehervidor, text="Tasa de circulación DEA", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta4.place(x=400,y=105, width=170,  height=20)
                valor4 = Entry(rehervidor, bg="white", fg="blue", justify=CENTER, textvariable=num1_var)
                valor4.place(x=580, y=105, width=80, height=20)
                etiqueta4u = Label(rehervidor, text="USGPM", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta4u.place(x=670,y=105, width=70,  height=20)

                etiqueta5 = Label(rehervidor, text="Duty del rehervidor", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta5.place(x=400,y=155, width=170,  height=20)
                valor5 = Entry(rehervidor, bg="white", fg="blue", justify=CENTER, textvariable=num2_var)
                valor5.place(x=580, y=155, width=80, height=20)
                etiqueta5u = Label(rehervidor, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta5u.place(x=670,y=155, width=70,  height=20)

                calculadora.leer_datos()
                num1_var.set(calculadora.calcular_tasa_circulacion())
                num2_var.set(calculadora.Dutyrehervidor())

                def ir_atras1():
                    rehervidor.withdraw()


                boton1 = Button(rehervidor, text='Atras', command=ir_atras1)
                boton1.place(x=640,y=300, width=90, height=25)

                rehervidor.mainloop()

            # Carga la imagen de rehervidor
            imagenreh= Image.open("Imagen7.png")
            rehervidor = ImageTk.PhotoImage(imagenreh)
            # Establece la imagen del rehervidor como un boton
            botton_imagen4 = Button(planta1, image=rehervidor, borderwidth=1, command=ventana_rehervidor, highlightcolor='blue')
            botton_imagen4.place(x=786, y=425)

            def ventana_cooler():
                calculadora=CalculadoraDEA()
                #Configurar la ventana. Titulo, tamaño y color de fondo
                cooler=Toplevel()
                cooler.title("Diseño del aeroenfriador de amina")
                cooler.geometry("780x410+340+100")
                cooler.configure(bg='white')
                #Permite que el usuario no maximice la pagina
                cooler.resizable(0,0)

                #Líneas Verticales y Horizontales
                #linea Vertical Izquierda
                lvi=Label(cooler, relief="groove")
                lvi.place(x=10, y=10, width=2, height=390)
                #linea Vertical Derecha
                lvd=Label(cooler, relief="groove")
                lvd.place(x=770, y=10, width=2, height=390)
                #linea Vertical media
                lvm=Label(cooler, relief="groove")
                lvm.place(x=360, y=20, width=2, height=370)
                #linea Horizontal Superior
                lhs=Label(cooler, relief="groove")
                lhs.place(x=10, y=10, width=760, height=2)    
                #linea Horizontal Inferior
                lhi=Label(cooler, relief="groove")
                lhi.place(x=10, y=400, width=760, height=2)
                #linea Horizontal media
                lhm=Label(cooler, relief="groove")
                lhm.place(x=370, y=340, width=390, height=2)

                # Carga la imagen del equipo
                imagen = Image.open("cooler.png")
                imagen = imagen.resize((310, 300), Image.LANCZOS)
                fondo_imagen = ImageTk.PhotoImage(imagen)
                # Establece la imagen del equipo
                equipo_cooler = Label(cooler, image=fondo_imagen, anchor='center', borderwidth=2, relief='groove', background='white')
                equipo_cooler.place(x=30, y=55, width=310, height=300)

                num1_var = tk.DoubleVar(value=0)
                num2_var = tk.DoubleVar(value=0)
                num3_var = tk.DoubleVar(value=0)
                num4_var = tk.DoubleVar(value=0)

                #Etiquetas, entry y posicionamiento de la cooler del gas
                etiqueta0 = Label(cooler, text="Cálculo del Duty del enfriador de amina pobre", relief="flat", bg='white', anchor='w')
                etiqueta0.place(x=380,y=40, width=270,  height=30)

                #Etiquetas, entry y posicionamiento de la cooler del gas
                etiqueta1 = Label(cooler, text="Temperatura entrada DEA al contactor", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta1.place(x=390, y=90, width=210,  height=20)
                valor1 = Entry(cooler, bg="white", fg="blue", justify=CENTER, textvariable=num1_var, state='readonly')
                valor1.place(x=610, y=90, width=80, height=20)
                etiqueta1u = Label(cooler, text="°F", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta1u.place(x=700,y=90, width=70,  height=20)

                etiqueta2 = Label(cooler, text="Temperatura salida DEA del IC", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta2.place(x=390,y=135, width=200,  height=20)
                valor2 = Entry(cooler, bg="white", fg="blue", justify=CENTER, textvariable=num2_var, state='readonly')
                valor2.place(x=610, y=135, width=80, height=20)
                etiqueta2u = Label(cooler, text="°F", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta2u.place(x=700,y=135, width=70,  height=20)

                etiqueta3 = Label(cooler, text="Flujo másico de DEA pobre", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta3.place(x=390,y=180, width=200,  height=20)
                valor3 = Entry(cooler, bg="white", fg="blue", justify=CENTER, textvariable=num3_var, state='readonly')
                valor3.place(x=610, y=180, width=80, height=20)
                etiqueta3u = Label(cooler, text="lb/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta3u.place(x=700,y=180, width=70,  height=20)

                etiqueta4 = Label(cooler, text="Duty del enfriador de amina", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta4.place(x=390,y=225, width=200,  height=20)
                valor4 = Entry(cooler, bg="white", fg="blue", justify=CENTER, textvariable=num4_var, state='readonly')
                valor4.place(x=610, y=225, width=80, height=20)
                etiqueta4u = Label(cooler, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta4u.place(x=700,y=225, width=70,  height=20)

                calculadora.leer_datos()
                num1_var.set(calculadora.Tgi+10)
                num2_var.set(calculadora.Tout_leanamineHX())
                var1=calculadora.calcular_tasa_circulacion()*60*8.71
                num3_var.set(round(var1))
                num4_var.set(calculadora.Duty_cooler())

                def ir_atras1():
                    cooler.withdraw()


                boton1 = Button(cooler, text='Atras', command=ir_atras1)
                boton1.place(x=660,y=360, width=90, height=25)

                cooler.mainloop()

            # Carga la imagen de cooler
            imagencooler= Image.open("Imagen6.png")
            cooler = ImageTk.PhotoImage(imagencooler)
            # Establece la imagen del cooler como un boton
            botton_imagen5 = Button(planta1, image=cooler, borderwidth=1, command=ventana_cooler, highlightcolor='blue')
            botton_imagen5.place(x=370, y=172)

            def ventana_condensador():
                calculadora=CalculadoraDEA()
                calculadora.leer_datos()
                #Configurar la ventana. Titulo, tamaño y color de fondo
                condensador=Toplevel()
                condensador.title("Diseño del condensador y tasa de reflujo de la unidad de regeneración")
                condensador.geometry("780x600+340+50")
                condensador.configure(bg='white')
                #Permite que el usuario no maximice la pagina
                condensador.resizable(0,0)

                #Líneas Verticales y Horizontales
                #linea Vertical Izquierda
                lvi=Label(condensador, relief="groove")
                lvi.place(x=10, y=10, width=2, height=580)
                #linea Vertical Derecha
                lvd=Label(condensador, relief="groove")
                lvd.place(x=770, y=10, width=2, height=580)
                #linea Vertical media
                lvm=Label(condensador, relief="groove")
                lvm.place(x=360, y=20, width=2, height=5600)
                #linea Horizontal Superior
                lhs=Label(condensador, relief="groove")
                lhs.place(x=10, y=10, width=760, height=2)    
                #linea Horizontal Inferior
                lhi=Label(condensador, relief="groove")
                lhi.place(x=10, y=590, width=760, height=2)
                #linea Horizontal media
                lhm=Label(condensador, relief="groove")
                lhm.place(x=370, y=530, width=390, height=2)

                # Carga la imagen del equipo
                imagen = Image.open("condensador.png")
                imagen = imagen.resize((310, 380), Image.LANCZOS)
                fondo_imagen = ImageTk.PhotoImage(imagen)
                # Establece la imagen del equipo
                equipo_condensador = Label(condensador, image=fondo_imagen, anchor='center', borderwidth=2, relief='groove', background='white')
                equipo_condensador.place(x=30, y=110, width=310, height=380)

                num1_var = tk.DoubleVar(value=0)
                num2_var = tk.DoubleVar(value=0)
                num3_var = tk.DoubleVar(value=0)
                num4_var = tk.DoubleVar(value=0)
                num5_var = tk.DoubleVar(value=0)
                num6_var = tk.DoubleVar(value=0)
                num7_var = tk.DoubleVar(value=0)
                num8_var = tk.DoubleVar(value=0)
                num9_var = tk.DoubleVar(value=0)
                num10_var = tk.DoubleVar(value=0)
                num11_var = tk.DoubleVar(value=0)
                num12_var = tk.DoubleVar(value=0)
                num13_var = tk.DoubleVar(value=0)
                num14_var = tk.DoubleVar(value=0)
                num15_var = tk.DoubleVar(value=0)
                num16_var = tk.DoubleVar(value=0)


                #Etiquetas, entry y posicionamiento de la condensador del gas
                etiqueta0 = Label(condensador, text="Cálculo del vapor de despojo", relief="flat", bg='white', anchor='w')
                etiqueta0.place(x=380,y=30, width=270,  height=30)

                #Etiquetas, entry y posicionamiento de la condensador del gas
                etiqueta1 = Label(condensador, text="Temperatura ambiente", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta1.place(x=390, y=70, width=210,  height=20)
                valor1 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num1_var, state='readonly')
                valor1.place(x=610, y=70, width=80, height=20)
                etiqueta1u = Label(condensador, text="°F", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta1u.place(x=700,y=70, width=70,  height=20)
            
                etiqueta2 = Label(condensador, text="ΔT ambiente/condensador", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta2.place(x=390,y=95, width=200,  height=20)
                valor2 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num2_var, state='readonly')
                valor2.place(x=610, y=95, width=80, height=20)
                etiqueta2u = Label(condensador, text="°F", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta2u.place(x=700,y=95, width=70,  height=20)
            
                etiqueta3 = Label(condensador, text="Presión del acumulador de reflujo", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta3.place(x=390,y=120, width=200,  height=20)
                valor3 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num3_var, state='readonly')
                valor3.place(x=610, y=120, width=80, height=20)
                etiqueta3u = Label(condensador, text="psig", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta3u.place(x=700,y=120, width=70,  height=20)
                
                etiqueta4 = Label(condensador, text="Flujo de gas ácido", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta4.place(x=390,y=145, width=200,  height=20)
                valor4 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num4_var, state='readonly')
                valor4.place(x=610, y=145, width=80, height=20)
                etiqueta4u = Label(condensador, text="lbmol/d", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta4u.place(x=700,y=145, width=70,  height=20)
            
                etiqueta5 = Label(condensador, text="Presión parcial de agua @T condensador", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta5.place(x=390,y=170, width=200,  height=20)
                valor5 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num5_var, state='readonly')
                valor5.place(x=610, y=170, width=80, height=20)
                etiqueta5u = Label(condensador, text="psia", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta5u.place(x=700,y=170, width=70,  height=20)
                
                etiqueta6 = Label(condensador, text="Flujo de vapor ácido que sale", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta6.place(x=390,y=195, width=200,  height=20)
                valor6 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num6_var, state='readonly')
                valor6.place(x=610, y=195, width=80, height=20)
                etiqueta6u = Label(condensador, text="lbmol/d", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta6u.place(x=700,y=195, width=70,  height=20)

                etiqueta7 = Label(condensador, text="Flujo de vapor de agua que sale", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta7.place(x=390,y=220, width=200,  height=20)
                valor7 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num7_var, state='readonly')
                valor7.place(x=610, y=220, width=80, height=20)
                etiqueta7u = Label(condensador, text="lbmol/d", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta7u.place(x=700,y=220, width=70,  height=20)

                etiqueta8 = Label(condensador, text="Flujo de vapor de agua perdido", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta8.place(x=390,y=245, width=200,  height=20)
                valor8 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num8_var, state='readonly')
                valor8.place(x=610, y=245, width=80, height=20)
                etiqueta8u = Label(condensador, text="MMSCFD", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta8u.place(x=700,y=245, width=70,  height=20)

                etiqueta00 = Label(condensador, text="Cálculo del duty del condensador", relief="flat", bg='white', anchor='w')
                etiqueta00.place(x=380,y=285, width=270,  height=30)

                etiqueta9 = Label(condensador, text="Duty de reacción por CO2", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta9.place(x=390,y=325, width=200,  height=20)
                valor9 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num9_var, state='readonly')
                valor9.place(x=610, y=325, width=80, height=20)
                etiqueta9u = Label(condensador, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta9u.place(x=700,y=325, width=70,  height=20)

                etiqueta10 = Label(condensador, text="Duty de reacción por H2S", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta10.place(x=390,y=350, width=200,  height=20)
                valor10 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num10_var, state='readonly')
                valor10.place(x=610, y=350, width=80, height=20)
                etiqueta10u = Label(condensador, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta10u.place(x=700,y=350, width=70,  height=20)

                etiqueta11 = Label(condensador, text="Duty del rehervidor", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta11.place(x=390,y=375, width=200,  height=20)
                valor11 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num11_var, state='readonly')
                valor11.place(x=610, y=375, width=80, height=20)
                etiqueta11u = Label(condensador, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta11u.place(x=700,y=375, width=70,  height=20)

                etiqueta12 = Label(condensador, text="Flujo amina pobre", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta12.place(x=390,y=400, width=200,  height=20)
                valor12 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num12_var, state='readonly')
                valor12.place(x=610, y=400, width=80, height=20)
                etiqueta12u = Label(condensador, text="lb/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta12u.place(x=700,y=400, width=70,  height=20)

                etiqueta13 = Label(condensador, text="Temperatura DEA sale rehervidor", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta13.place(x=390,y=425, width=200,  height=20)
                valor13 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num13_var, state='readonly')
                valor13.place(x=610, y=425, width=80, height=20)
                etiqueta13u = Label(condensador, text="°F", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta13u.place(x=700,y=425, width=70,  height=20)

                etiqueta14 = Label(condensador, text="Temperatura DEA entra rehervidor", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta14.place(x=390,y=450, width=200,  height=20)
                valor14 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num14_var, state='readonly')
                valor14.place(x=610, y=450, width=80, height=20)
                etiqueta14u = Label(condensador, text="°F", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta14u.place(x=700,y=450, width=70,  height=20)

                etiqueta15 = Label(condensador, text="Duty ganado DEA en el rehervidor", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta15.place(x=390,y=475, width=200,  height=20)
                valor15 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num15_var, state='readonly')
                valor15.place(x=610, y=475, width=80, height=20)
                etiqueta15u = Label(condensador, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta15u.place(x=700,y=475, width=70,  height=20)

                etiqueta16 = Label(condensador, text="Duty del condensador", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta16.place(x=390,y=500, width=200,  height=20)
                valor16 = Entry(condensador, bg="white", fg="blue", justify=CENTER, textvariable=num16_var, state='readonly')
                valor16.place(x=610, y=500, width=80, height=20)
                etiqueta16u = Label(condensador, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta16u.place(x=700,y=500, width=70,  height=20)

                def ir_atras1():
                    condensador.withdraw()
                
                num1_var.set(calculadora.Tamb)
                num2_var.set(value=30)
                num3_var.set(value=10) #Presion reflujo
                num4_var.set(round(calculadora.Mol_CO2_abs()+calculadora.Mol_H2S_abs()))
                num5_var.set(round(calculadora.PresionParcial(num1_var.get()+num2_var.get()),2))
                var1 = (num3_var.get()+14.7)*num4_var.get()
                var2 = (num3_var.get()+14.7)-num5_var.get()
                num6_var.set(round(var1/var2))
                num7_var.set(round(num6_var.get()-calculadora.Mol_CO2_abs()))
                num8_var.set(calculadora.Vapor_despojo())
                num9_var.set(calculadora.DutyReaccionCO2())
                num10_var.set(calculadora.DutyReaccionH2S())
                num11_var.set(calculadora.Dutyrehervidor())
                num12_var.set(round(calculadora.calcular_tasa_circulacion()*60*calculadora.Dsolucion))
                num13_var.set(value=250)
                num14_var.set(value=220)
                var1 = num12_var.get()*calculadora.CpDEA*(250-220)/1000000
                num15_var.set(round(var1,2))
                num16_var.set(round(num11_var.get()-num15_var.get()-num9_var.get()-num10_var.get(),2))

                boton1 = Button(condensador, text='Atras', command=ir_atras1)
                boton1.place(x=660,y=550, width=90, height=25)

                condensador.mainloop()

            # Carga la imagen de condensador
            imagencond= Image.open("Imagen8.png")
            condensador = ImageTk.PhotoImage(imagencond)
            # Establece la imagen del condensador como un boton
            botton_imagen6 = Button(planta1, image=condensador, borderwidth=1, command=ventana_condensador, highlightcolor='blue')
            botton_imagen6.place(x=765, y=10)

            def ventana_separador():
                #Configurar la ventana. Titulo, tamaño y color de fondo
                separador=Toplevel()
                separador.title("Separador flash")
                separador.geometry("800x560+340+80")
                separador.configure(bg='white')
                #Permite que el usuario no maximice la pagina
                separador.resizable(0,0)

                #Líneas Verticales y Horizontales
                #linea Vertical Izquierda
                lvi=Label(separador, relief="groove")
                lvi.place(x=10, y=10, width=2, height=540)
                #linea Vertical Derecha
                lvd=Label(separador, relief="groove")
                lvd.place(x=790, y=10, width=2, height=540)
                #linea Horizontal Superior
                lhs=Label(separador, relief="groove")
                lhs.place(x=10, y=10, width=780, height=2)    
                #linea Horizontal Inferior
                lhi=Label(separador, relief="groove")
                lhi.place(x=10, y=550, width=780, height=2)
                #linea Horizontal media
                lmi=Label(separador, relief="groove")
                lmi.place(x=20, y=490, width=760, height=2)


                # Carga la imagen del equipo
                imagen = Image.open("separador.png")
                imagen = imagen.resize((700, 440), Image.LANCZOS)
                fondo_imagen = ImageTk.PhotoImage(imagen)
                # Establece la imagen del equipo
                equipo_separador = Label(separador, image=fondo_imagen, anchor='center', borderwidth=2, relief='groove', background='white')
                equipo_separador.place(x=50, y=50, width=700, height=440)


                #Etiquetas, entry y posicionamiento de la separador del gas
                etiqueta0 = Label(separador, text="SEPARADOR FLASH", relief="flat", bg='white', anchor='c', font=14)
                etiqueta0.place(x=20,y=20, width=760,  height=30)


                def ir_atras1():
                    separador.withdraw()


                boton1 = Button(separador, text='Atras', command=ir_atras1)
                boton1.place(x=680,y=510, width=90, height=25)

                separador.mainloop()

            # Carga la imagen de sep Flash
            imagenflash= Image.open("Imagen9.png")
            flash = ImageTk.PhotoImage(imagenflash)
            # Establece la imagen del separador como un boton
            botton_imagen7 = Button(planta1, image=flash, borderwidth=1, command=ventana_separador, highlightcolor='blue')
            botton_imagen7.place(x=349, y=353)

            def ventana_bomba():
                calculadora = CalculadoraDEA()
                #Configurar la ventana. Titulo, tamaño y color de fondo
                bomba=Toplevel()
                bomba.title("Diseño del bomba")
                bomba.geometry("760x350+340+100")
                bomba.configure(bg='white')
                #Permite que el usuario no maximice la pagina
                bomba.resizable(0,0)

                #Líneas Verticales y Horizontales
                #linea Vertical Izquierda
                lvi=Label(bomba, relief="groove")
                lvi.place(x=10, y=10, width=2, height=330)
                #linea Vertical Derecha
                lvd=Label(bomba, relief="groove")
                lvd.place(x=750, y=10, width=2, height=330)
                #linea Vertical media
                lvm=Label(bomba, relief="groove")
                lvm.place(x=360, y=20, width=2, height=310)
                #linea Horizontal Superior
                lhs=Label(bomba, relief="groove")
                lhs.place(x=10, y=10, width=740, height=2)    
                #linea Horizontal Inferior
                lhi=Label(bomba, relief="groove")
                lhi.place(x=10, y=340, width=740, height=2)
                #linea Horizontal media
                lhm=Label(bomba, relief="groove")
                lhm.place(x=370, y=280, width=370, height=2)

                # Carga la imagen del equipo
                imagen = Image.open("bomba1.png")
                imagen = imagen.resize((310, 200), Image.LANCZOS)
                fondo_imagen = ImageTk.PhotoImage(imagen)
                # Establece la imagen del equipo
                equipo_bomba = Label(bomba, image=fondo_imagen, anchor='center', borderwidth=2, relief='groove', background='white')
                equipo_bomba.place(x=30, y=75, width=310, height=200)

                num1_var = tk.DoubleVar(value=0)
                num2_var = tk.DoubleVar(value=0)
                num3_var = tk.DoubleVar(value=0)
                num4_var = tk.DoubleVar(value=0)

                #Etiquetas, entry y posicionamiento de la bomba del gas
                etiqueta0 = Label(bomba, text="Cálculo la potencia de la bomba", relief="flat", bg='white', anchor='w')
                etiqueta0.place(x=390,y=50, width=270,  height=30)

                #Etiquetas, entry y posicionamiento de la bomba del gas
                etiqueta1 = Label(bomba, text="Tasa de circulación DEA", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta1.place(x=400,y=105, width=170,  height=20)
                valor1 = Entry(bomba, bg="white", fg="blue", justify=CENTER, textvariable=num1_var, state='readonly')
                valor1.place(x=580, y=105, width=80, height=20)
                etiqueta1u = Label(bomba, text="USGPM", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta1u.place(x=670,y=105, width=70,  height=20)

                etiqueta2 = Label(bomba, text=" ΔPresión de la bomba", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta2.place(x=400,y=145, width=170,  height=20)
                valor2 = Entry(bomba, bg="white", fg="blue", justify=CENTER, textvariable=num2_var, state='readonly')
                valor2.place(x=580, y=145, width=80, height=20)
                etiqueta2u = Label(bomba, text="psi", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta2u.place(x=670,y=145, width=70,  height=20)

                etiqueta3 = Label(bomba, text="Eficiencia de la bomba", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta3.place(x=400,y=185, width=170,  height=20)
                valor3 = Entry(bomba, bg="white", fg="blue", justify=CENTER, textvariable=num3_var, state='readonly')
                valor3.place(x=580, y=185, width=80, height=20)

                etiqueta4 = Label(bomba, text="Potencia requerida por bomba", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta4.place(x=400,y=225, width=170,  height=20)
                valor4 = Entry(bomba, bg="white", fg="blue", justify=CENTER, textvariable=num4_var, state='readonly')
                valor4.place(x=580, y=225, width=80, height=20)
                etiqueta4u = Label(bomba, text="BHP", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta4u.place(x=670,y=225, width=70,  height=20)

                def ir_atras1():
                    bomba.withdraw()

                calculadora.leer_datos()
                num1_var.set(calculadora.calcular_tasa_circulacion())
                num2_var.set(value=40)
                num3_var.set(value=0.65)
                var1 = num1_var.get()*num2_var.get()/(num3_var.get()*1714)
                num4_var.set(round(var1,1))

                boton1 = Button(bomba, text='Atras', command=ir_atras1)
                boton1.place(x=640,y=300, width=90, height=25)

                bomba.mainloop()

            # Carga la imagen de bomba
            imagenbomba= Image.open("Imagen10.png")
            bomba = ImageTk.PhotoImage(imagenbomba)
            # Establece la imagen de la bomba como un boton
            botton_imagen8 = Button(planta1, image=bomba, borderwidth=1, command=ventana_bomba, highlightcolor='blue')
            botton_imagen8.place(x=649, y=526)

            def ventana_reflujo():
                calculadora = CalculadoraDEA()
                #Configurar la ventana. Titulo, tamaño y color de fondo
                reflujo=Toplevel()
                reflujo.title("Diseño del reflujo")
                reflujo.geometry("760x450+340+100")
                reflujo.configure(bg='white')
                #Permite que el usuario no maximice la pagina
                reflujo.resizable(0,0)

                #Líneas Verticales y Horizontales
                #linea Vertical Izquierda
                lvi=Label(reflujo, relief="groove")
                lvi.place(x=10, y=10, width=2, height=430)
                #linea Vertical Derecha
                lvd=Label(reflujo, relief="groove")
                lvd.place(x=750, y=10, width=2, height=430)
                #linea Vertical media
                lvm=Label(reflujo, relief="groove")
                lvm.place(x=360, y=20, width=2, height=410)
                #linea Horizontal Superior
                lhs=Label(reflujo, relief="groove")
                lhs.place(x=10, y=10, width=740, height=2)    
                #linea Horizontal Inferior
                lhi=Label(reflujo, relief="groove")
                lhi.place(x=10, y=440, width=740, height=2)
                #linea Horizontal media
                lhm=Label(reflujo, relief="groove")
                lhm.place(x=370, y=380, width=370, height=2)

                # Carga la imagen del equipo
                imagen = Image.open("reflujo.png")
                imagen = imagen.resize((410, 400), Image.LANCZOS)
                fondo_imagen = ImageTk.PhotoImage(imagen)
                # Establece la imagen del equipo
                equipo_reflujo = Label(reflujo, image=fondo_imagen, anchor='center', borderwidth=2, relief='groove', background='white')
                equipo_reflujo.place(x=30, y=75, width=310, height=300)

                num1_var = tk.DoubleVar(value=0)
                num2_var = tk.DoubleVar(value=0)
                num3_var = tk.DoubleVar(value=0)
                num4_var = tk.DoubleVar(value=0)
                num5_var = tk.DoubleVar(value=0)
                num6_var = tk.DoubleVar(value=0)
                num7_var = tk.DoubleVar(value=0)
                num8_var = tk.DoubleVar(value=0)
                num9_var = tk.DoubleVar(value=0)
                num10_var = tk.DoubleVar(value=0)
                num11_var = tk.DoubleVar(value=0)

                #Etiquetas, entry y posicionamiento de la reflujo del gas
                etiqueta0 = Label(reflujo, text="Cálculo de la tasa de reflujo", relief="flat", bg='white', anchor='w')
                etiqueta0.place(x=390,y=40, width=270,  height=30)

                #Etiquetas, entry y posicionamiento de la reflujo del gas
                etiqueta1 = Label(reflujo, text="Temperatura plato superior", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta1.place(x=400,y=80, width=170,  height=20)
                valor1 = Entry(reflujo, bg="white", fg="blue", justify=CENTER, textvariable=num1_var, state='readonly')
                valor1.place(x=580, y=80, width=80, height=20)
                etiqueta1u = Label(reflujo, text="°F", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta1u.place(x=670,y=80, width=70,  height=20)

                etiqueta2 = Label(reflujo, text=" Temperatura condensador", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta2.place(x=400,y=105, width=170,  height=20)
                valor2 = Entry(reflujo, bg="white", fg="blue", justify=CENTER, textvariable=num2_var, state='readonly')
                valor2.place(x=580, y=105, width=80, height=20)
                etiqueta2u = Label(reflujo, text="°F", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta2u.place(x=670,y=105, width=70,  height=20)

                etiqueta3 = Label(reflujo, text="Flujo de gas ácido", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta3.place(x=400,y=130, width=170,  height=20)
                valor3 = Entry(reflujo, bg="white", fg="blue", justify=CENTER, textvariable=num3_var, state='readonly')
                valor3.place(x=580, y=130, width=80, height=20)
                etiqueta3u = Label(reflujo, text="lbm/d", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta3u.place(x=670,y=130, width=70,  height=20)

                etiqueta4 = Label(reflujo, text="Duty para enfriar gas ácido", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta4.place(x=400,y=155, width=170,  height=20)
                valor4 = Entry(reflujo, bg="white", fg="blue", justify=CENTER, textvariable=num4_var, state='readonly')
                valor4.place(x=580, y=155, width=80, height=20)
                etiqueta4u = Label(reflujo, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta4u.place(x=670,y=155, width=70,  height=20)

                etiqueta5 = Label(reflujo, text="Duty condensador", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta5.place(x=400,y=180, width=170,  height=20)
                valor5 = Entry(reflujo, bg="white", fg="blue", justify=CENTER, textvariable=num5_var, state='readonly')
                valor5.place(x=580, y=180, width=80, height=20)
                etiqueta5u = Label(reflujo, text="MMBTU/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta5u.place(x=670,y=180, width=70,  height=20)

                etiqueta6 = Label(reflujo, text="Tasa de reflujo", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta6.place(x=400,y=205, width=170,  height=20)
                valor6 = Entry(reflujo, bg="white", fg="blue", justify=CENTER, textvariable=num6_var, state='readonly')
                valor6.place(x=580, y=205, width=80, height=20)
                etiqueta6u = Label(reflujo, text="lb/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta6u.place(x=670,y=205, width=70,  height=20)

                etiqueta7 = Label(reflujo, text="Flujo vapor H2O sale cond", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta7.place(x=400,y=230, width=170,  height=20)
                valor7 = Entry(reflujo, bg="white", fg="blue", justify=CENTER, textvariable=num7_var, state='readonly')
                valor7.place(x=580, y=230, width=80, height=20)
                etiqueta7u = Label(reflujo, text="lbm/d", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta7u.place(x=670,y=230, width=70,  height=20)

                etiqueta8 = Label(reflujo, text="Flujo GA + H2O sale plato sup", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta8.place(x=400,y=255, width=170,  height=20)
                valor8 = Entry(reflujo, bg="white", fg="blue", justify=CENTER, textvariable=num8_var, state='readonly')
                valor8.place(x=580, y=255, width=80, height=20)
                etiqueta8u = Label(reflujo, text="lbm/d", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta8u.place(x=670,y=255, width=70,  height=20)

                etiqueta9 = Label(reflujo, text="Flujo H2O plato sup", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta9.place(x=400,y=280, width=170,  height=20)
                valor9 = Entry(reflujo, bg="white", fg="blue", justify=CENTER, textvariable=num9_var, state='readonly')
                valor9.place(x=580, y=280, width=80, height=20)
                etiqueta9u = Label(reflujo, text="lbm/d", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta9u.place(x=670,y=280, width=70,  height=20)

                etiqueta10 = Label(reflujo, text="Flujo gas ácido sale cond", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta10.place(x=400,y=305, width=170,  height=20)
                valor10 = Entry(reflujo, bg="white", fg="blue", justify=CENTER, textvariable=num10_var, state='readonly')
                valor10.place(x=580, y=305, width=80, height=20)
                etiqueta10u = Label(reflujo, text="lbm/hr", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta10u.place(x=670,y=305, width=70,  height=20)

                etiqueta11= Label(reflujo, text="Relación de reflujo", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta11.place(x=400,y=330, width=170,  height=20)
                valor11 = Entry(reflujo, bg="white", fg="blue", justify=CENTER, textvariable=num11_var, state='readonly')
                valor11.place(x=580, y=330, width=80, height=20)
                etiqueta11u = Label(reflujo, text="lbm/lbm", relief="flat", bg='white', fg="gray26", anchor='w')
                etiqueta11u.place(x=670,y=330, width=70,  height=20)

                def ir_atras1():
                    reflujo.withdraw()

                calculadora.leer_datos()
                num1_var.set(value=210)
                num2_var.set(calculadora.Tamb + 30)
                num3_var.set(calculadora.Mol_CO2_abs() + calculadora.Mol_H2S_abs())
                num4_var.set(round((num3_var.get()/24)*0.65*44*(num1_var.get()-num2_var.get())/1000000,2))
                num5_var.set(calculadora.Duty_condensador())
                temperatura=[32,35,40,45,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,212,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,520,540,560,580,600,620,640,660,680,700,705.4]
                Presionabs=[0.08854,0.09995,0.1217,0.14752,0.17811,0.2563,0.3631,0.5069,0.6982,0.9492,12748,16924,22225,23886,3718,4741,5992,7.51,9339,11526,14123,14696,17186,20.78,24969,29825,35429,41858,49203,57556,67013,77.68,89.66,103.06,118.01,134.63,153.04,173.37,195.77,220.37,247.31,276.75,308.83,343.72,381.59,422.6,466.9,514.7,566.1,621.4,680.8,812.4,962.5,1133.1,1325.8,1542.9,1736.6,2059.7,2365.4,2708.1,3093.7,3206.2]
                entalpialiq=[0,3.02,8.05,13.06,18.07,28.06,38.04,48.02,57.99,67.97,77.94,87.92,97.9,107.89,117.89,127.89,137.9,147.92,157.95,167.99,178.05,180.07,188.13,198.23,208.34,216.48,228.64,238.84,249.06,259.31,269.59,279.92,290.28,300.68,311.13,321.63,332.18,342.79,353.45,364.17,374.97,385.83,396.77,407.79,418.9,430.1,441.4,452.8,464.4,476,487.8,511.9,536.6,562.2,588.9,617,646.7,678.6,714.2,757.3,823.3,902.7]
                entalpiavapor=[1075.8,1077.1,1079.3,1081.5,1083.7,1088,1092.3,1096.6,1100.9,1105.2,1109.5,1113.7,1117.9,1122,1126.1,1130.2,1134.2,1138.1,1142,1145.9,1149.7,1150.4,1153.4,1157,1160.5,1164,1167.3,1170.6,1173.8,1176.8,1179.7,1182.5,1185.2,1187.7,1190.1,1192.3,1194.4,1196.3,1198.1,1199.6,1201,1202.1,1203.1,1203.8,1204.3,1204.6,1204.6,1204.3,1203.7,1202.8,1201.7,1198.2,1193.2,1186.4,1177.3,1165.3,1150.3,1130.5,1104.4,1067.2,995.4,902.7]
                intepentalpiavapor=np.interp(num1_var.get(),temperatura,entalpiavapor)
                num6_var.set(round((num5_var.get()-num4_var.get())*1000000/(intepentalpiavapor-180)))
                variable1=num3_var.get()+(num6_var.get()+788)/18*24
                num7_var.set(round(variable1))
                num8_var.set(round(num7_var.get()+num3_var.get()))
                num9_var.set(round(num7_var.get()-num3_var.get()))
                presionparcial=num9_var.get()*24.7/num7_var.get()
                inteptemperatura=np.interp(presionparcial,Presionabs,temperatura)
                num12=inteptemperatura
                while num12 !=inteptemperatura:
                    calculadora.leer_datos()
                    num1_var.set(num12)
                    num2_var.set(calculadora.Tamb + 30)
                    num3_var.set(calculadora.Mol_CO2_abs() + calculadora.Mol_H2S_abs())
                    num4_var.set(round((num3_var.get()/24)*0.65*44*(num1_var.get()-num2_var.get())/1000000,2))
                    num5_var.set(calculadora.Duty_condensador())
                    temperatura=[32,35,40,45,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,212,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,520,540,560,580,600,620,640,660,680,700,705.4]
                    Presionabs=[0.08854,0.09995,0.1217,0.14752,0.17811,0.2563,0.3631,0.5069,0.6982,0.9492,12748,16924,22225,23886,3718,4741,5992,7.51,9339,11526,14123,14696,17186,20.78,24969,29825,35429,41858,49203,57556,67013,77.68,89.66,103.06,118.01,134.63,153.04,173.37,195.77,220.37,247.31,276.75,308.83,343.72,381.59,422.6,466.9,514.7,566.1,621.4,680.8,812.4,962.5,1133.1,1325.8,1542.9,1736.6,2059.7,2365.4,2708.1,3093.7,3206.2]
                    entalpialiq=[0,3.02,8.05,13.06,18.07,28.06,38.04,48.02,57.99,67.97,77.94,87.92,97.9,107.89,117.89,127.89,137.9,147.92,157.95,167.99,178.05,180.07,188.13,198.23,208.34,216.48,228.64,238.84,249.06,259.31,269.59,279.92,290.28,300.68,311.13,321.63,332.18,342.79,353.45,364.17,374.97,385.83,396.77,407.79,418.9,430.1,441.4,452.8,464.4,476,487.8,511.9,536.6,562.2,588.9,617,646.7,678.6,714.2,757.3,823.3,902.7]
                    entalpiavapor=[1075.8,1077.1,1079.3,1081.5,1083.7,1088,1092.3,1096.6,1100.9,1105.2,1109.5,1113.7,1117.9,1122,1126.1,1130.2,1134.2,1138.1,1142,1145.9,1149.7,1150.4,1153.4,1157,1160.5,1164,1167.3,1170.6,1173.8,1176.8,1179.7,1182.5,1185.2,1187.7,1190.1,1192.3,1194.4,1196.3,1198.1,1199.6,1201,1202.1,1203.1,1203.8,1204.3,1204.6,1204.6,1204.3,1203.7,1202.8,1201.7,1198.2,1193.2,1186.4,1177.3,1165.3,1150.3,1130.5,1104.4,1067.2,995.4,902.7]
                    intepentalpiavapor=np.interp(num1_var.get(),temperatura,entalpiavapor)
                    intepentalpialiq=np.interp(num1_var.get(),temperatura,entalpialiq)
                    num6_var.set(round((num5_var.get()-num4_var.get())*1000000/(intepentalpiavapor-intepentalpialiq)))
                    variable1=num3_var.get()+(num6_var.get()+788)/18*24
                    num7_var.set(round(variable1))
                    num8_var.set(round(num7_var.get()+num3_var.get()))
                    num9_var.set(round(num7_var.get()-num3_var.get()))
                    presionparcial=num9_var.get()*24.7/num7_var.get()
                    inteptemperatura=np.interp(presionparcial,Presionabs,temperatura)
                    num12=inteptemperatura
                
                num10_var.set(round(calculadora.Vapor_acido()/24))
                num11_var.set(round(num10_var.get()/(num7_var.get()/24),2))

                boton1 = Button(reflujo, text='Atras', command=ir_atras1)
                boton1.place(x=640,y=400, width=90, height=25)

                reflujo.mainloop()

            # Carga la imagen de reflujo
            imagenreflujo= Image.open("Imagen11.png")
            reflujo = ImageTk.PhotoImage(imagenreflujo)
            # Establece la imagen del tanque reflujo como un boton
            botton_imagen9 = Button(planta1, image=reflujo, borderwidth=1, command=ventana_reflujo, highlightcolor='blue')
            botton_imagen9.place(x=847, y=86)

            def ir_atras1():
                planta1.withdraw()

            # Establece y posiciona el boton atras
            botton_imagen6 = Button(planta1, text='Atras', command=ir_atras1)
            botton_imagen6.place(x=400, y=570, width=90, height=25)


            planta1.mainloop()

        #Botón llama la siguiente ventana para empezar el diseño
        btndiseño = Button(composicion, text="Diseñar", bg="white", command=ventana_planta, state='disabled')
        btndiseño.place(x=535, y=475, width=60, height=25)

        def ir_atras():
            composicion.withdraw()
    
        #Crear un boton para calcular emisiones
        boton1 = Button(composicion, text="Atras", command=ir_atras)
        boton1.place(x=650,y=475, width=60, height=25)

        
        composicion.mainloop()


    #Funcion que llama la ventana emisiones
    def ventana_emisiones():
        #Configurar la ventana. Titulo, tamaño y color de fondo
        emisiones=Toplevel()
        emisiones.title("Datos para el calculo de emisiones con DEA")
        emisiones.geometry("740x520+340+50")
        emisiones.configure(bg='white')
        #Permite que el usuario no maximice la pagina
        emisiones.resizable(0,0)


        #Líneas Verticales y Horizontales
        #linea Vertical Izquierda
        lvi=Label(emisiones, relief="groove")
        lvi.place(x=10, y=10, width=2, height=500)
        #linea Vertical Derecha
        lvd=Label(emisiones, relief="groove")
        lvd.place(x=730, y=10, width=2, height=500)
        #linea Horizontal Superior
        lhs=Label(emisiones, relief="groove")
        lhs.place(x=10, y=10, width=720, height=2)    
        #linea Horizontal Inferior
        lhi=Label(emisiones, relief="groove")
        lhi.place(x=10, y=510, width=720, height=2)
        #linea Horizontal medio
        lhm=Label(emisiones, relief="groove")
        lhm.place(x=20, y=250, width=700, height=2)

        #Crear las variables de control
        num1_var = tk.DoubleVar(value=25)
        num2_var = tk.DoubleVar(value=50)
        num3_var = tk.DoubleVar(value=230)
        num4_var = tk.DoubleVar(value=550)
        num5_var = tk.DoubleVar(value=900)
        num6_var = tk.DoubleVar(value=80)


        #crear y posicionar etiquetas y textbox  
        etiqueta0=Label(emisiones, bg="white", text="Datos de entrada del modelo", relief="flat", justify="center", anchor='w')
        etiqueta0.place(x=40, y=30, width=220, height=30)

        etiqueta1=Label(emisiones, bg="white", text="Presión del gas de entrada", relief="flat", fg="gray26", anchor='w') 
        etiqueta1.place(x=60,y=65, width=200, height=20)
        valor1 = Entry(emisiones, bg="white", fg="blue", justify=CENTER, textvariable=num5_var)
        valor1.place(x=500, y=65, width=90, height=20)
        etiqueta11=Label(emisiones, bg="white", text="psia", relief="flat", fg="gray26", anchor='w') 
        etiqueta11.place(x=600,y=65, width=80, height=20)

        etiqueta2=Label(emisiones, bg="white", text="Temperatura del gas de entrada", relief="flat", fg="gray26", anchor='w')
        etiqueta2.place(x=60,y=90, width=200, height=20)
        valor2 = Entry(emisiones, bg="white", fg="blue", justify=CENTER, textvariable=num6_var)
        valor2.place(x=500, y=90, width=90, height=20)
        etiqueta22=Label(emisiones, bg="white", text="°F", relief="flat", fg="gray26", anchor='w')
        etiqueta22.place(x=600,y=90, width=80, height=20)

        etiqueta3=Label(emisiones, bg="white", text="Flujo de gas", relief="flat", fg="gray26", anchor='w' )
        etiqueta3.place(x=60,y=115, width=200, height=20)
        valor3 = Entry(emisiones, bg="white", fg="blue", justify=CENTER, textvariable=num2_var)
        valor3.place(x=500, y=115, width=90, height=20)
        etiqueta3=Label(emisiones, bg="white", text="MMSCFD", relief="flat", fg="gray26", anchor='w' )
        etiqueta3.place(x=600,y=115, width=80, height=20)

        etiqueta4=Label(emisiones, bg="white", text="Tasa de circulación de DEA", relief="flat", fg="gray26", anchor='w' )
        etiqueta4.place(x=60,y=140, width=200, height=20)
        valor4 = Entry(emisiones, bg="white", fg="blue", justify=CENTER, textvariable=num4_var)
        valor4.place(x=500, y=140, width=90, height=20)
        etiqueta44=Label(emisiones, bg="white", text="USGPM", relief="flat", fg="gray26", anchor='w' )
        etiqueta44.place(x=600,y=140, width=80, height=20)

        etiqueta5=Label(emisiones, bg="white", text="Porcentaje en peso de DEA", relief="flat", fg="gray26", anchor='w' )
        etiqueta5.place(x=60,y=165, width=200, height=20)
        valor5 = Entry(emisiones, bg="white", fg="blue", justify=CENTER, textvariable=num1_var)
        valor5.place(x=500, y=165, width=90, height=20)
        etiqueta55=Label(emisiones, bg="white", text="%", relief="flat", fg="gray26", anchor='w' )
        etiqueta55.place(x=600,y=165, width=80, height=20)

        etiqueta6=Label(emisiones, bg="white", text="Temperatura del rehervidor", relief="flat", fg="gray26", anchor='w' )
        etiqueta6.place(x=60,y=190, width=200, height=20)
        valor6 = Entry(emisiones, bg="white", fg="blue", justify=CENTER, textvariable=num3_var)
        valor6.place(x=500, y=190, width=90, height=20)
        etiqueta6=Label(emisiones, bg="white", text="°F", relief="flat", fg="gray26", anchor='w' )
        etiqueta6.place(x=600,y=190, width=80, height=20)

        # Función de validación para comprobar si el valor introducido es un número
        def validar_numero(valor):
            try:
                float(valor)
                return True
            except ValueError:
                return False
            
        # Configurar validación
        validacion = emisiones.register(validar_numero)
        valor1.config(validate="key", validatecommand=(validacion, '%P'))
        valor2.config(validate="key", validatecommand=(validacion, '%P'))
        valor3.config(validate="key", validatecommand=(validacion, '%P'))
        valor4.config(validate="key", validatecommand=(validacion, '%P'))
        valor5.config(validate="key", validatecommand=(validacion, '%P'))
        valor6.config(validate="key", validatecommand=(validacion, '%P'))

        #Etiquetas del calculo de emisiones
        etiqueta7=Label(emisiones, bg="white", text="Emisiones CO2", relief="flat", fg="gray26", anchor='w' )
        etiqueta7.place(x=20,y=280, width=200, height=20)
        etiqueta8=Label(emisiones, bg="white", text="Emisiones CH4", relief="flat", fg="gray26", anchor='w' )
        etiqueta8.place(x=20,y=390, width=200, height=20)

        # crea las imágenes
        imagen1 = Image.open("EcuacionCO2.jpg")
        imagen1 = imagen1.resize((500, 60), Image.LANCZOS)
        imagen1_tk = ImageTk.PhotoImage(imagen1)
        imagen2 = Image.open("EcuacionCH4.jpg")
        imagen2 = imagen2.resize((500, 60), Image.LANCZOS)
        imagen2_tk = ImageTk.PhotoImage(imagen2)

        # Crear etiqueta y establecer su imagen
        etiqueta_imagen1 = Label(emisiones, image=imagen1_tk, bg='white', justify='center')
        etiqueta_imagen1.place(x=20,y=310)
        etiqueta_imagen2 = Label(emisiones, image=imagen2_tk, bg='white', justify='center')
        etiqueta_imagen2.place(x=20,y=420)
        etiqueta9=Label(emisiones, bg="white", text="lb/hr", relief="flat", fg="gray26", anchor='w' )
        etiqueta9.place(x=650,y=330, width=40, height=20)
        etiqueta10=Label(emisiones, bg="white", text="lb/hr", relief="flat", fg="gray26", anchor='w' )
        etiqueta10.place(x=650,y=440, width=40, height=20)


        resultado_co2=DoubleVar()
        resultado_ch4=DoubleVar()
        resultadoco2_entry = Entry(emisiones, textvariable=resultado_co2, state='readonly', justify='center')
        resultadoco2_entry.place(x=550,y=330, width=90, height=20)
        resultadoch4_entry = Entry(emisiones, textvariable=resultado_ch4, state='readonly', justify='center')
        resultadoch4_entry.place(x=550,y=440, width=90, height=20)

        # Función para realizar la suma y mostrar el resultado
        def operar():
            num1 = num1_var.get()
            num2 = num2_var.get()
            num3 = num3_var.get()
            num4 = num4_var.get()
            num5 = num5_var.get()
            num6 = num6_var.get()
            resultado1 = 6700.31 + 175.994*num1 + 134.448*num2 - 32.6542*num3 + 0.371227*num4 -0.00743519*num5 - 116.376*num6 - 0.677292*num1**2 - 0.646156*num1*num3 +0.0145171*num1*num4 + 0.240028*num1*num6 + 0.176554*num2*num3 -0.0899319*num2*num6 + 0.564604*num3*num6 - 0.151199*num6**2
            resultado_co2.set(round(resultado1,2))
            resultado2= 100.052 + 0.329812*num1 - 1.20475*num2 - 0.353346*num3 + 0.0748065*num4 + 0.000481481*num5 - 1.38721*num6 - 0.00612963*num1**2 + 0.000879012*num1*num2 - 0.00187407*num1*num3 +0.00539015*num1*num6 + 0.00395333*num2*num3 + 0.00452222*num3*num6 - 0.000235985*num4*num6 + 0.00074537*num6**2
            resultado_ch4.set(round(resultado2,2))

        def ir_atras():
            emisiones.withdraw()

        #Crear un boton para calcular emisiones
        boton1 = Button(emisiones, text="Calcular", command=operar)
        boton1.place(x=550,y=220, width=90, height=25)

        boton2 = Button(emisiones, text="Atras", command=ir_atras)
        boton2.place(x=550,y=480, width=90, height=25)

        emisiones.mainloop()

    # crea las etiquetas y botones y los posiciona en la ventana
    etiqueta1 = Label(seleccion, image=imagen1_tk,  anchor="center", bg="white")
    etiqueta1.place(x=25, y=40)
    etiqueta11 = Label(seleccion, text='Módulo de diseño de una planta', anchor="center", bg="white")
    etiqueta11.place(x=12, y=260, width=288)
    etiqueta12 = Label(seleccion, text='de endulzamiento de gas natural con DEA', anchor="center", bg="white")
    etiqueta12.place(x=12, y=280, width=288)
    #etiqueta13 = Label(seleccion, text='con DEA', anchor="center", bg="white")
    #etiqueta13.place(x=24, y=290, width=175)
    boton1 = Button(seleccion, text="Diseñar",relief="raised", command=ventana_diseño)
    boton1.place(x=105, y=320, width=80, height=30)

    etiqueta2 = Label(seleccion, image=imagen2_tk, justify="center",  anchor="center", bg="white")
    etiqueta2.place(x=315, y=40)
    etiqueta21 = Label(seleccion, text='Módulo de emisiones de GEI en plantas', anchor="center", bg="white")
    etiqueta21.place(x=302, y=260, width=288)
    etiqueta22 = Label(seleccion, text='de endulzamiento de GN con DEA', anchor="center", bg="white")
...     etiqueta22.place(x=302, y=280, width=288)
...     #etiqueta23 = Label(seleccion, text='de gas natural con DEA', anchor="center", bg="white")
...     #etiqueta23.place(x=310, y=290, width=175)
...     boton2 = Button(seleccion, text="Emisiones", relief="raised", command=ventana_emisiones)
...     boton2.place(x=405, y=320, width=80, height=30)
... 
...     def ir_atras():
...         seleccion.withdraw()
... 
...     boton2 = Button(seleccion, text="Atras", command=ir_atras)
...     boton2.place(x=255,y=340, width=90, height=30)
...         
...         
...     # inicia la seleccion
...     seleccion.mainloop()
... 
...    
... ################################################
... #==============FIN MÓDULO ENDULZAMIENTO========#
... ################################################
... 
